‪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  'blank input' => [
29  [ // TypoLinkCodecService::decode() result of input value from link field
30  'url' => '',
31  'target' => '',
32  'class' => '',
33  'title' => '',
34  'additionalParams' => '',
35  ],
36  [ // ViewHelper arguments
37  'target' => '',
38  'class' => '',
39  'title' => '',
40  'additionalParams' => '',
41  ],
42  [ // expectation
43  'url' => '',
44  'target' => '',
45  'class' => '',
46  'title' => '',
47  'additionalParams' => '',
48  ],
49  ],
50  'empty input' => [
51  [],
52  [
53  'target' => '',
54  'class' => '',
55  'title' => '',
56  'additionalParams' => '',
57  ],
58  [],
59  ],
60  'simple id input' => [
61  [
62  'url' => 19,
63  'target' => '',
64  'class' => '',
65  'title' => '',
66  'additionalParams' => '',
67  ],
68  [
69  'target' => '',
70  'class' => '',
71  'title' => '',
72  'additionalParams' => '',
73  ],
74  [
75  'url' => 19,
76  'target' => '',
77  'class' => '',
78  'title' => '',
79  'additionalParams' => '',
80  ],
81  ],
82  'external url with target' => [
83  [
84  'url' => 'www.web.de',
85  'target' => '_blank',
86  'class' => '',
87  'title' => '',
88  'additionalParams' => '',
89  ],
90  [
91  'target' => '',
92  'class' => '',
93  'title' => '',
94  'additionalParams' => '',
95  ],
96  [
97  'url' => 'www.web.de',
98  'target' => '_blank',
99  'class' => '',
100  'title' => '',
101  'additionalParams' => '',
102  ],
103  ],
104  'page with extended class' => [
105  [
106  'url' => 42,
107  'target' => '',
108  'class' => 'css-class',
109  'title' => '',
110  'additionalParams' => '',
111  ],
112  [
113  'target' => '',
114  'class' => 'fluid-class',
115  'title' => '',
116  'additionalParams' => '',
117  ],
118  [
119  'url' => 42,
120  'target' => '',
121  'class' => 'css-class fluid-class',
122  'title' => '',
123  'additionalParams' => '',
124  ],
125  ],
126  'page with same class' => [
127  [
128  'url' => 42,
129  'target' => '',
130  'class' => 'css-class',
131  'title' => '',
132  'additionalParams' => '',
133  ],
134  [
135  'target' => '',
136  'class' => 'css-class',
137  'title' => '',
138  'additionalParams' => '',
139  ],
140  [
141  'url' => 42,
142  'target' => '',
143  'class' => 'css-class',
144  'title' => '',
145  'additionalParams' => '',
146  ],
147  ],
148  'page with overridden title' => [
149  [
150  'url' => 42,
151  'target' => '',
152  'class' => '',
153  'title' => 'a link title',
154  'additionalParams' => '',
155  ],
156  [
157  'target' => '',
158  'class' => '',
159  'title' => 'another link title',
160  'additionalParams' => '',
161  ],
162  [
163  'url' => 42,
164  'target' => '',
165  'class' => '',
166  'title' => 'another link title',
167  'additionalParams' => '',
168  ],
169  ],
170  'page with title and extended parameters' => [
171  [
172  'url' => 42,
173  'target' => '',
174  'class' => '',
175  'title' => 'a link title',
176  'additionalParams' => '&x=y',
177  ],
178  [
179  'target' => '',
180  'class' => '',
181  'title' => '',
182  'additionalParams' => '&a=b',
183  ],
184  [
185  'url' => 42,
186  'target' => '',
187  'class' => '',
188  'title' => 'a link title',
189  'additionalParams' => '&x=y&a=b',
190  ],
191  ],
192  'overwrite all' => [
193  [
194  'url' => 42,
195  'target' => '_top',
196  'class' => 'css-class',
197  'title' => 'a link title',
198  'additionalParams' => '&x=y',
199  ],
200  [
201  'target' => '_blank',
202  'class' => 'fluid-class',
203  'title' => 'another link title',
204  'additionalParams' => '&a=b',
205  ],
206  [
207  'url' => 42,
208  'target' => '_blank',
209  'class' => 'css-class fluid-class',
210  'title' => 'another link title',
211  'additionalParams' => '&x=y&a=b',
212  ],
213  ],
214  ];
215  }
216 
222  array $decodedConfiguration,
223  array $viewHelperArguments,
224  array $expectation
225  ): void {
226  $subject = $this->getAccessibleMock(TypolinkViewHelper::class, ['renderChildren']);
227  $result = $subject->_call(
228  'mergeTypoLinkConfiguration',
229  $decodedConfiguration,
230  $viewHelperArguments
231  );
232  self::assertSame($expectation, $result);
233  }
234 }