[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / LinkHandling / UrlLinkHandlerTest.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\UrlLinkHandler;
18
19 class UrlLinkHandlerTest extends \TYPO3\CMS\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 'URL without a scheme' => [
31 [
32 'url' => 'www.have.you/ever?did=this'
33 ],
34 [
35 'url' => 'http://www.have.you/ever?did=this'
36 ],
37 'http://www.have.you/ever?did=this'
38 ],
39 'http URL' => [
40 [
41 'url' => 'http://www.have.you/ever?did=this'
42 ],
43 [
44 'url' => 'http://www.have.you/ever?did=this'
45 ],
46 'http://www.have.you/ever?did=this'
47 ],
48 'https URL' => [
49 [
50 'url' => 'https://www.have.you/ever?did=this'
51 ],
52 [
53 'url' => 'https://www.have.you/ever?did=this'
54 ],
55 'https://www.have.you/ever?did=this'
56 ],
57 'https URL with port' => [
58 [
59 'url' => 'https://www.have.you:8088/ever?did=this'
60 ],
61 [
62 'url' => 'https://www.have.you:8088/ever?did=this'
63 ],
64 'https://www.have.you:8088/ever?did=this'
65 ],
66 'ftp URL' => [
67 [
68 'url' => 'ftp://www.have.you/ever?did=this'
69 ],
70 [
71 'url' => 'ftp://www.have.you/ever?did=this'
72 ],
73 'ftp://www.have.you/ever?did=this'
74 ],
75 'afp URL' => [
76 [
77 'url' => 'afp://www.have.you/ever?did=this'
78 ],
79 [
80 'url' => 'afp://www.have.you/ever?did=this'
81 ],
82 'afp://www.have.you/ever?did=this'
83 ],
84 'sftp URL' => [
85 [
86 'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
87 ],
88 [
89 'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
90 ],
91 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
92 ]
93 ];
94 }
95
96 /**
97 * @test
98 *
99 * @param string $input
100 * @param array $expected
101 * @param string $finalString
102 *
103 * @dataProvider resolveParametersForNonFilesDataProvider
104 */
105 public function resolveReturnsSplitParameters($input, $expected, $finalString)
106 {
107 $subject = new UrlLinkHandler();
108 $this->assertEquals($expected, $subject->resolveHandlerData($input));
109 }
110
111 /**
112 * @test
113 *
114 * @param string $input
115 * @param array $parameters
116 * @param string $expected
117 *
118 * @dataProvider resolveParametersForNonFilesDataProvider
119 */
120 public function splitParametersToUnifiedIdentifier($input, $parameters, $expected)
121 {
122 $subject = new UrlLinkHandler();
123 $this->assertEquals($expected, $subject->asString($parameters));
124 }
125 }