‪TYPO3CMS  11.5
TypolinkViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
23 class ‪TypolinkViewHelperTest extends UnitTestCase
24 {
26  {
27  return [
28  'empty input' => [
29  [], // TypoLinkCodecService::decode() result of input value from link field
30  ],
31  'simple id input' => [
32  [
33  'url' => 19,
34  'target' => '',
35  'class' => '',
36  'title' => '',
37  'additionalParams' => '',
38  ],
39  ],
40  'external url with target' => [
41  [
42  'url' => 'www.web.de',
43  'target' => '_blank',
44  'class' => '',
45  'title' => '',
46  'additionalParams' => '',
47  ],
48  ],
49  'page with class' => [
50  [
51  'url' => 'www.web.de',
52  'target' => '',
53  'class' => 'css-class',
54  'title' => '',
55  'additionalParams' => '',
56  ],
57  ],
58  'page with title' => [
59  [
60  'url' => 'www.web.de',
61  'target' => '',
62  'class' => '',
63  'title' => 'a link title',
64  'additionalParams' => '',
65  ],
66  ],
67  'page with title and parameters' => [
68  [
69  'url' => 'www.web.de',
70  'target' => '',
71  'class' => '',
72  'title' => 'a link title',
73  'additionalParams' => '&x=y',
74  ],
75  ],
76  ];
77  }
78 
83  public function ‪mergeTypoLinkConfigurationDoesNotModifyData(array $decodedConfiguration): void
84  {
85  $subject = $this->getAccessibleMock(TypolinkViewHelper::class, ['dummy']);
86  $result = $subject->_call('mergeTypoLinkConfiguration', $decodedConfiguration, []);
87  self::assertSame($decodedConfiguration, $result);
88  }
89 
91  {
92  return [
93  'empty input' => [
94  [], // TypoLinkCodecService::decode() result of input value from link field
95  [], // ViewHelper arguments
96  [], // expected typolink configuration
97  ],
98  'page with title and extended parameters' => [
99  [
100  'url' => 42,
101  'target' => '',
102  'class' => '',
103  'title' => 'a link title',
104  'additionalParams' => '&x=y',
105  ],
106  [
107  'additionalParams' => '&a=b',
108  ],
109  [
110  'url' => 42,
111  'target' => '',
112  'class' => '',
113  'title' => 'a link title',
114  'additionalParams' => '&x=y&a=b',
115  ],
116  ],
117  'only page id and overwrite' => [
118  [
119  'url' => 42,
120  'target' => '',
121  'class' => '',
122  'title' => '',
123  'additionalParams' => '',
124  ],
125  [
126  'additionalParams' => '&a=b',
127  ],
128  [
129  'url' => 42,
130  'target' => '',
131  'class' => '',
132  'title' => '',
133  'additionalParams' => '&a=b',
134  ],
135  ],
136  't3:// with title and extended parameters' => [
137  [
138  'url' => 't3://url?url=https://example.org?param=1&other=dude',
139  'target' => '',
140  'class' => '',
141  'title' => 'a link title',
142  'additionalParams' => '&x=y',
143  ],
144  [
145  'additionalParams' => '&a=b',
146  ],
147  [
148  'url' => 't3://url?url=https://example.org?param=1&other=dude',
149  'target' => '',
150  'class' => '',
151  'title' => 'a link title',
152  'additionalParams' => '&x=y&a=b',
153  ],
154  ],
155  't3:// and overwrite' => [
156  [
157  'url' => 't3://url?url=https://example.org?param=1&other=dude',
158  'target' => '',
159  'class' => '',
160  'title' => '',
161  'additionalParams' => '',
162  ],
163  [
164  'additionalParams' => '&a=b',
165  ],
166  [
167  'url' => 't3://url?url=https://example.org?param=1&other=dude',
168  'target' => '',
169  'class' => '',
170  'title' => '',
171  'additionalParams' => '&a=b',
172  ],
173  ],
174  ];
175  }
176 
181  public function ‪mergeTypoLinkConfigurationMergesData(array $decodedConfiguration, array $viewHelperArguments, array $expected): void
182  {
183  $subject = $this->getAccessibleMock(TypolinkViewHelper::class, ['dummy']);
184  $result = $subject->_call('mergeTypoLinkConfiguration', $decodedConfiguration, $viewHelperArguments);
185  self::assertSame($expected, $result);
186  }
187 }
‪TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Uri
Definition: TypolinkViewHelperTest.php:18