2 namespace TYPO3\CMS\Core\Tests\Unit\LinkHandling
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Core\LinkHandling\LinkService
;
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase
;
20 class LinkServiceTest
extends UnitTestCase
23 * Data to resolve strings to arrays and vice versa, external, mail, page
27 public function resolveParametersForNonFilesDataProvider()
30 'simple page - old style' => [
31 // original input value
35 'type' => LinkService
::TYPE_PAGE
,
41 'page with type - old style' => [
44 'type' => LinkService
::TYPE_PAGE
,
48 't3://page?uid=13&type=31'
50 'page with type and fragment - old style' => [
53 'type' => LinkService
::TYPE_PAGE
,
56 'fragment' => 'uncool'
58 't3://page?uid=13&type=31#uncool'
60 'page with type and parameters and fragment - old style' => [
61 '13,31?unbel=ievable#uncool',
63 'type' => LinkService
::TYPE_PAGE
,
66 'parameters' => 'unbel=ievable',
67 'fragment' => 'uncool'
69 't3://page?uid=13&type=31&unbel=ievable#uncool'
71 'page with alias - old style' => [
74 'type' => LinkService
::TYPE_PAGE
,
75 'pagealias' => 'alias13'
77 't3://page?alias=alias13'
80 'http://www.have.you/ever?did=this',
82 'type' => LinkService
::TYPE_URL
,
83 'url' => 'http://www.have.you/ever?did=this'
85 'http://www.have.you/ever?did=this'
87 'http URL without scheme' => [
88 'www.have.you/ever?did=this',
90 'type' => LinkService
::TYPE_URL
,
91 'url' => 'http://www.have.you/ever?did=this'
93 'http://www.have.you/ever?did=this'
96 'https://www.have.you/ever?did=this',
98 'type' => LinkService
::TYPE_URL
,
99 'url' => 'https://www.have.you/ever?did=this'
101 'https://www.have.you/ever?did=this'
103 'https URL with port' => [
104 'https://www.have.you:8088/ever?did=this',
106 'type' => LinkService
::TYPE_URL
,
107 'url' => 'https://www.have.you:8088/ever?did=this'
109 'https://www.have.you:8088/ever?did=this'
112 'ftp://www.have.you/ever?did=this',
114 'type' => LinkService
::TYPE_URL
,
115 'url' => 'ftp://www.have.you/ever?did=this'
117 'ftp://www.have.you/ever?did=this'
120 'afp://www.have.you/ever?did=this',
122 'type' => LinkService
::TYPE_URL
,
123 'url' => 'afp://www.have.you/ever?did=this'
125 'afp://www.have.you/ever?did=this'
128 'sftp://nice:andsecret@www.have.you:23/ever?did=this',
130 'type' => LinkService
::TYPE_URL
,
131 'url' => 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
133 'sftp://nice:andsecret@www.have.you:23/ever?did=this'
135 'email with protocol' => [
136 'mailto:one@love.com',
138 'type' => LinkService
::TYPE_EMAIL
,
139 'email' => 'one@love.com'
141 'mailto:one@love.com'
143 'email without protocol' => [
146 'type' => LinkService
::TYPE_EMAIL
,
147 'email' => 'one@love.com'
149 'mailto:one@love.com'
151 'current page - cool style' => [
152 't3://page?uid=current',
154 'type' => LinkService
::TYPE_PAGE
,
155 'pageuid' => 'current'
157 't3://page?uid=current'
159 'current empty page - cool style' => [
162 'type' => LinkService
::TYPE_PAGE
,
163 'pageuid' => 'current'
165 't3://page?uid=current'
167 'simple page - cool style' => [
170 'type' => LinkService
::TYPE_PAGE
,
175 'page with alias - cool style' => [
176 't3://page?alias=alias13',
178 'type' => LinkService
::TYPE_PAGE
,
179 'pagealias' => 'alias13'
181 't3://page?alias=alias13'
183 'page with alias and type - cool style' => [
184 't3://page?alias=alias13&type=31',
186 'type' => LinkService
::TYPE_PAGE
,
187 'pagealias' => 'alias13',
190 't3://page?alias=alias13&type=31'
192 'page with alias and parameters - cool style' => [
193 't3://page?alias=alias13&my=additional¶meter=that&are=nice',
195 'type' => LinkService
::TYPE_PAGE
,
196 'pagealias' => 'alias13',
197 'parameters' => 'my=additional¶meter=that&are=nice'
199 't3://page?alias=alias13&my=additional¶meter=that&are=nice',
201 'page with alias and parameters and fragment - cool style' => [
202 't3://page?alias=alias13&my=additional¶meter=that&are=nice#again',
204 'type' => LinkService
::TYPE_PAGE
,
205 'pagealias' => 'alias13',
206 'parameters' => 'my=additional¶meter=that&are=nice',
207 'fragment' => 'again'
209 't3://page?alias=alias13&my=additional¶meter=that&are=nice#again',
217 * @param string $input
218 * @param array $expected
219 * @param string $finalString
221 * @dataProvider resolveParametersForNonFilesDataProvider
223 public function resolveReturnsSplitParameters($input, $expected, $finalString)
225 $subject = new LinkService();
226 $this->assertEquals($expected, $subject->resolve($input));
232 * @param string $input
233 * @param array $parameters
234 * @param string $expected
236 * @dataProvider resolveParametersForNonFilesDataProvider
238 public function splitParametersToUnifiedIdentifier($input, $parameters, $expected)
240 $subject = new LinkService();
241 $this->assertEquals($expected, $subject->asString($parameters));