a6a127ea9f68a09198c3550daa93d4452cde107c
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / LinkHandling / EmailLinkHandlerTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\LinkHandling;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\LinkHandling\EmailLinkHandler;
18
19 class EmailLinkHandlerTest extends \TYPO3\Components\TestingFramework\Core\UnitTestCase
20 {
21
22 /**
23 * Data to resolve strings to arrays and vice versa, external, mail, page
24 *
25 * @return array
26 */
27 public function resolveParametersForNonFilesDataProvider()
28 {
29 return [
30 'email with protocol' => [
31 [
32 'email' => 'mailto:one@love.com'
33 ],
34 [
35 'email' => 'one@love.com'
36 ],
37 'mailto:one@love.com'
38 ],
39 'email with protocol 2' => [
40 [
41 'email' => 'mailto:info@typo3.org'
42 ],
43 [
44 'email' => 'info@typo3.org'
45 ],
46 'mailto:info@typo3.org'
47 ],
48 ];
49 }
50
51 /**
52 * @test
53 *
54 * @param string $input
55 * @param array $expected
56 * @param string $finalString
57 *
58 * @dataProvider resolveParametersForNonFilesDataProvider
59 */
60 public function resolveReturnsSplitParameters($input, $expected, $finalString)
61 {
62 $subject = new EmailLinkHandler();
63 $this->assertEquals($expected, $subject->resolveHandlerData($input));
64 }
65
66 /**
67 * @test
68 *
69 * @param string $input
70 * @param array $parameters
71 * @param string $expected
72 *
73 * @dataProvider resolveParametersForNonFilesDataProvider
74 */
75 public function splitParametersToUnifiedIdentifier($input, $parameters, $expected)
76 {
77 $subject = new EmailLinkHandler();
78 $this->assertEquals($expected, $subject->asString($parameters));
79 }
80 }