[BUGFIX] Add possibility to use session data in TS conditions
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Unit / Configuration / TypoScript / ConditionMatching / ConditionMatcherTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching;
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 Prophecy\Argument;
18 use TYPO3\CMS\Core\Configuration\TypoScript\Exception\InvalidTypoScriptConditionException;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
21 use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
22 use TYPO3\CMS\Frontend\Tests\Unit\Configuration\TypoScript\ConditionMatching\Fixtures\TestConditionException;
23
24 /**
25 * Test case
26 */
27 class ConditionMatcherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
29 /**
30 * @var string Name of a key in $GLOBALS for this test
31 */
32 protected $testGlobalNamespace;
33
34 /**
35 * @var \TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher Class under test
36 */
37 protected $matchCondition;
38
39 protected function setUp()
40 {
41 $this->testGlobalNamespace = $this->getUniqueId('TEST');
42 GeneralUtility::flushInternalRuntimeCaches();
43 $GLOBALS[$this->testGlobalNamespace] = [];
44 $GLOBALS['TSFE'] = new \stdClass();
45 $GLOBALS['TSFE']->tmpl = new \stdClass();
46 $GLOBALS['TSFE']->tmpl->rootLine = [
47 2 => ['uid' => 121, 'pid' => 111],
48 1 => ['uid' => 111, 'pid' => 101],
49 0 => ['uid' => 101, 'pid' => 0]
50 ];
51 $this->matchCondition = GeneralUtility::makeInstance(ConditionMatcher::class);
52 }
53
54 /**
55 * Tests whether a faulty expression fails.
56 *
57 * @test
58 */
59 public function simulateDisabledMatchAllConditionsFailsOnFaultyExpression()
60 {
61 $this->matchCondition->matchAll = false;
62 $this->assertFalse($this->matchCondition->match('[nullCondition = This expression would return FALSE in general]'));
63 }
64
65 /**
66 * Tests whether simulating positive matches for all conditions succeeds.
67 *
68 * @test
69 */
70 public function simulateEnabledMatchAllConditionsSucceeds()
71 {
72 $this->matchCondition->setSimulateMatchResult(true);
73 $this->assertTrue($this->matchCondition->match('[nullCondition = This expression would return FALSE in general]'));
74 }
75
76 /**
77 * Tests whether simulating positive matches for specific conditions succeeds.
78 *
79 * @test
80 */
81 public function simulateEnabledMatchSpecificConditionsSucceeds()
82 {
83 $testCondition = '[' . $this->getUniqueId('test') . ' = Any condition to simulate a positive match]';
84 $this->matchCondition->setSimulateMatchConditions([$testCondition]);
85 $this->assertTrue($this->matchCondition->match($testCondition));
86 }
87
88 /**
89 * Tests whether the language comparison matches.
90 *
91 * @test
92 */
93 public function languageConditionMatchesSingleLanguageExpression()
94 {
95 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
96 $this->assertTrue($this->matchCondition->match('[language = *de*]'));
97 $this->assertTrue($this->matchCondition->match('[language = *de-de*]'));
98 }
99
100 /**
101 * Tests whether the language comparison matches.
102 *
103 * @test
104 */
105 public function languageConditionMatchesMultipleLanguagesExpression()
106 {
107 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
108 $this->assertTrue($this->matchCondition->match('[language = *en*,*de*]'));
109 $this->assertTrue($this->matchCondition->match('[language = *en-us*,*de-de*]'));
110 }
111
112 /**
113 * Tests whether the language comparison matches.
114 *
115 * @test
116 */
117 public function languageConditionMatchesCompleteLanguagesExpression()
118 {
119 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
120 $this->assertTrue($this->matchCondition->match('[language = de-de,de;q=0.8,en-us;q=0.5,en;q=0.3]'));
121 }
122
123 /**
124 * Tests whether usergroup comparison matches.
125 *
126 * @test
127 */
128 public function usergroupConditionMatchesSingleGroupId()
129 {
130 $GLOBALS['TSFE']->gr_list = '13,14,15';
131 $this->assertTrue($this->matchCondition->match('[usergroup = 13]'));
132 }
133
134 /**
135 * Tests whether usergroup comparison matches.
136 *
137 * @test
138 */
139 public function usergroupConditionMatchesMultipleUserGroupId()
140 {
141 $GLOBALS['TSFE']->gr_list = '13,14,15';
142 $this->assertTrue($this->matchCondition->match('[usergroup = 999,15,14,13]'));
143 }
144
145 /**
146 * Tests whether usergroup comparison matches.
147 *
148 * @test
149 */
150 public function usergroupConditionDoesNotMatchDefaulUserGroupIds()
151 {
152 $GLOBALS['TSFE']->gr_list = '0,-1';
153 $this->assertFalse($this->matchCondition->match('[usergroup = 0,-1]'));
154 }
155
156 /**
157 * Tests whether user comparison matches.
158 *
159 * @test
160 */
161 public function loginUserConditionMatchesAnyLoggedInUser()
162 {
163 $GLOBALS['TSFE']->loginUser = true;
164 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
165 $this->assertTrue($this->matchCondition->match('[loginUser = *]'));
166 }
167
168 /**
169 * Tests whether user comparison matches.
170 *
171 * @test
172 */
173 public function loginUserConditionMatchesSingleLoggedInUser()
174 {
175 $GLOBALS['TSFE']->loginUser = true;
176 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
177 $this->assertTrue($this->matchCondition->match('[loginUser = 13]'));
178 }
179
180 /**
181 * Tests whether user comparison matches.
182 *
183 * @test
184 */
185 public function loginUserConditionMatchesMultipleLoggedInUsers()
186 {
187 $GLOBALS['TSFE']->loginUser = true;
188 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
189 $this->assertTrue($this->matchCondition->match('[loginUser = 999,13]'));
190 }
191
192 /**
193 * Tests whether user comparison matches.
194 *
195 * @test
196 */
197 public function loginUserConditionDoesNotMatchIfNotUserIsLoggedId()
198 {
199 $GLOBALS['TSFE']->loginUser = false;
200 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
201 $this->assertFalse($this->matchCondition->match('[loginUser = *]'));
202 $this->assertFalse($this->matchCondition->match('[loginUser = 13]'));
203 }
204
205 /**
206 * Tests whether user is not logged in
207 *
208 * @test
209 */
210 public function loginUserConditionMatchIfUserIsNotLoggedIn()
211 {
212 $GLOBALS['TSFE']->loginUser = false;
213 $this->assertTrue($this->matchCondition->match('[loginUser = ]'));
214 }
215
216 /**
217 * Tests whether numerical comparison matches.
218 *
219 * @test
220 */
221 public function globalVarConditionMatchesOnEqualExpression()
222 {
223 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 = 10]'));
224 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 = 10.1]'));
225 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 == 10]'));
226 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 == 10.1]'));
227 }
228
229 /**
230 * Tests whether numerical comparison matches.
231 *
232 * @test
233 */
234 public function globalVarConditionMatchesOnEqualExpressionWithMultipleValues()
235 {
236 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 = 10|20|30]'));
237 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 = 10.1|20.2|30.3]'));
238 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20 = 10|20|30]'));
239 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20.2 = 10.1|20.2|30.3]'));
240 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 == 10|20|30]'));
241 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 == 10.1|20.2|30.3]'));
242 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20 == 10|20|30]'));
243 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20.2 == 10.1|20.2|30.3]'));
244 }
245
246 /**
247 * Tests whether numerical comparison matches.
248 *
249 * @test
250 */
251 public function globalVarConditionMatchesOnNotEqualExpression()
252 {
253 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 != 20]'));
254 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 != 10.2]'));
255 }
256
257 /**
258 * Tests whether numerical comparison does not match.
259 *
260 * @test
261 */
262 public function globalVarConditionDoesNotMatchOnNotEqualExpression()
263 {
264 $this->assertFalse($this->matchCondition->match('[globalVar = LIT:10 != 10]'));
265 }
266
267 /**
268 * Tests whether numerical comparison matches.
269 *
270 * @test
271 */
272 public function globalVarConditionMatchesOnNotEqualExpressionWithMultipleValues()
273 {
274 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 != 20|30]'));
275 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 != 10.2|20.3]'));
276 }
277
278 /**
279 * Tests whether numerical comparison matches.
280 *
281 * @test
282 */
283 public function globalVarConditionMatchesOnLowerThanExpression()
284 {
285 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 < 20]'));
286 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 < 10.2]'));
287 }
288
289 /**
290 * Tests whether numerical comparison matches.
291 *
292 * @test
293 */
294 public function globalVarConditionMatchesOnLowerThanOrEqualExpression()
295 {
296 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 <= 10]'));
297 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 <= 20]'));
298 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 <= 10.1]'));
299 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 <= 10.2]'));
300 }
301
302 /**
303 * Tests whether numerical comparison matches.
304 *
305 * @test
306 */
307 public function globalVarConditionMatchesOnGreaterThanExpression()
308 {
309 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20 > 10]'));
310 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.2 > 10.1]'));
311 }
312
313 /**
314 * Tests whether numerical comparison matches.
315 *
316 * @test
317 */
318 public function globalVarConditionMatchesOnGreaterThanOrEqualExpression()
319 {
320 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 >= 10]'));
321 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20 >= 10]'));
322 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 >= 10.1]'));
323 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.2 >= 10.1]'));
324 }
325
326 /**
327 * Tests whether numerical comparison matches.
328 *
329 * @test
330 */
331 public function globalVarConditionMatchesOnEmptyExpressionWithNoValueSet()
332 {
333 $testKey = $this->getUniqueId('test');
334 $this->assertTrue($this->matchCondition->match('[globalVar = GP:' . $testKey . '=]'));
335 $this->assertTrue($this->matchCondition->match('[globalVar = GP:' . $testKey . ' = ]'));
336 }
337
338 /**
339 * Tests whether numerical comparison matches.
340 *
341 * @test
342 */
343 public function globalVarConditionDoesNotMatchOnEmptyExpressionWithValueSetToZero()
344 {
345 $testKey = $this->getUniqueId('test');
346 $_GET = [];
347 $_POST = [$testKey => 0];
348 $this->assertFalse($this->matchCondition->match('[globalVar = GP:' . $testKey . '=]'));
349 $this->assertFalse($this->matchCondition->match('[globalVar = GP:' . $testKey . ' = ]'));
350 }
351
352 /**
353 * Tests whether an array with zero as key matches its value
354 *
355 * @test
356 */
357 public function globalVarConditionMatchesOnArrayExpressionWithZeroAsKey()
358 {
359 $testKey = $this->getUniqueId('test');
360 $testValue = '1';
361 $_GET = [];
362 $_POST = [$testKey => ['0' => $testValue]];
363 $this->assertTrue($this->matchCondition->match('[globalVar = GP:' . $testKey . '|0=' . $testValue . ']'));
364 }
365
366 /**
367 * Tests whether string comparison matches.
368 *
369 * @test
370 */
371 public function globalStringConditionMatchesOnEqualExpression()
372 {
373 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3.Test.Condition]'));
374 $this->assertFalse($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3]'));
375 }
376
377 /**
378 * Tests whether string comparison matches.
379 *
380 * @test
381 */
382 public function globalStringConditionMatchesOnEmptyExpressionWithValueSetToEmptyString()
383 {
384 $testKey = $this->getUniqueId('test');
385 $_GET = [];
386 $_POST = [$testKey => ''];
387 $this->assertTrue($this->matchCondition->match('[globalString = GP:' . $testKey . '=]'));
388 $this->assertTrue($this->matchCondition->match('[globalString = GP:' . $testKey . ' = ]'));
389 }
390
391 /**
392 * Tests whether string comparison matches.
393 *
394 * @test
395 */
396 public function globalStringConditionMatchesOnEmptyLiteralExpressionWithValueSetToEmptyString()
397 {
398 $this->assertTrue($this->matchCondition->match('[globalString = LIT:=]'));
399 $this->assertTrue($this->matchCondition->match('[globalString = LIT: = ]'));
400 }
401
402 /**
403 * Tests whether string comparison matches.
404 *
405 * @test
406 */
407 public function globalStringConditionMatchesWildcardExpression()
408 {
409 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3?Test?Condition]'));
410 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3.T*t.Condition]'));
411 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3?T*t?Condition]'));
412 }
413
414 /**
415 * Tests whether string comparison matches.
416 *
417 * @test
418 */
419 public function globalStringConditionMatchesRegularExpression()
420 {
421 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = /^[A-Za-z3.]+$/]'));
422 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = /^TYPO3\\..+Condition$/]'));
423 $this->assertFalse($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = /^FALSE/]'));
424 }
425
426 /**
427 * Tests whether string comparison matches.
428 *
429 * @test
430 */
431 public function globalStringConditionMatchesEmptyRegularExpression()
432 {
433 $testKey = $this->getUniqueId('test');
434 $_SERVER[$testKey] = '';
435 $this->assertTrue($this->matchCondition->match('[globalString = _SERVER|' . $testKey . ' = /^$/]'));
436 }
437
438 /**
439 * Tests whether treeLevel comparison matches.
440 *
441 * @test
442 */
443 public function treeLevelConditionMatchesSingleValue()
444 {
445 $this->assertTrue($this->matchCondition->match('[treeLevel = 2]'));
446 }
447
448 /**
449 * Tests whether treeLevel comparison matches.
450 *
451 * @test
452 */
453 public function treeLevelConditionMatchesMultipleValues()
454 {
455 $this->assertTrue($this->matchCondition->match('[treeLevel = 999,998,2]'));
456 }
457
458 /**
459 * Tests whether treeLevel comparison matches.
460 *
461 * @test
462 */
463 public function treeLevelConditionDoesNotMatchFaultyValue()
464 {
465 $this->assertFalse($this->matchCondition->match('[treeLevel = 999]'));
466 }
467
468 /**
469 * Tests whether a page Id is found in the previous rootline entries.
470 *
471 * @test
472 */
473 public function PIDupinRootlineConditionMatchesSinglePageIdInRootline()
474 {
475 $GLOBALS['TSFE']->id = 121;
476 $this->assertTrue($this->matchCondition->match('[PIDupinRootline = 111]'));
477 }
478
479 /**
480 * Tests whether a page Id is found in the previous rootline entries.
481 *
482 * @test
483 */
484 public function PIDupinRootlineConditionMatchesMultiplePageIdsInRootline()
485 {
486 $GLOBALS['TSFE']->id = 121;
487 $this->assertTrue($this->matchCondition->match('[PIDupinRootline = 999,111,101]'));
488 }
489
490 /**
491 * Tests whether a page Id is found in the previous rootline entries.
492 *
493 * @test
494 */
495 public function PIDupinRootlineConditionDoesNotMatchPageIdNotInRootline()
496 {
497 $GLOBALS['TSFE']->id = 121;
498 $this->assertFalse($this->matchCondition->match('[PIDupinRootline = 999]'));
499 }
500
501 /**
502 * Tests whether a page Id is found in the previous rootline entries.
503 *
504 * @test
505 */
506 public function PIDupinRootlineConditionDoesNotMatchLastPageIdInRootline()
507 {
508 $GLOBALS['TSFE']->id = 121;
509 $this->assertFalse($this->matchCondition->match('[PIDupinRootline = 121]'));
510 }
511
512 /**
513 * Tests whether a page Id is found in all rootline entries.
514 *
515 * @test
516 */
517 public function PIDinRootlineConditionMatchesSinglePageIdInRootline()
518 {
519 $GLOBALS['TSFE']->id = 121;
520 $this->assertTrue($this->matchCondition->match('[PIDinRootline = 111]'));
521 }
522
523 /**
524 * Tests whether a page Id is found in all rootline entries.
525 *
526 * @test
527 */
528 public function PIDinRootlineConditionMatchesMultiplePageIdsInRootline()
529 {
530 $GLOBALS['TSFE']->id = 121;
531 $this->assertTrue($this->matchCondition->match('[PIDinRootline = 999,111,101]'));
532 }
533
534 /**
535 * Tests whether a page Id is found in all rootline entries.
536 *
537 * @test
538 */
539 public function PIDinRootlineConditionMatchesLastPageIdInRootline()
540 {
541 $GLOBALS['TSFE']->id = 121;
542 $this->assertTrue($this->matchCondition->match('[PIDinRootline = 121]'));
543 }
544
545 /**
546 * Tests whether a page Id is found in all rootline entries.
547 *
548 * @test
549 */
550 public function PIDinRootlineConditionDoesNotMatchPageIdNotInRootline()
551 {
552 $GLOBALS['TSFE']->id = 121;
553 $this->assertFalse($this->matchCondition->match('[PIDinRootline = 999]'));
554 }
555
556 /**
557 * Tests whether the compatibility version can be evaluated.
558 * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
559 *
560 * @test
561 */
562 public function compatVersionConditionMatchesOlderRelease()
563 {
564 $this->assertTrue($this->matchCondition->match('[compatVersion = 7.0]'));
565 }
566
567 /**
568 * Tests whether the compatibility version can be evaluated.
569 * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
570 *
571 * @test
572 */
573 public function compatVersionConditionMatchesSameRelease()
574 {
575 $this->assertTrue($this->matchCondition->match('[compatVersion = ' . TYPO3_branch . ']'));
576 }
577
578 /**
579 * Tests whether the compatibility version can be evaluated.
580 * (e.g. 7.9 is compatible to 7.0 but not to 15.0)
581 *
582 * @test
583 */
584 public function compatVersionConditionDoesNotMatchNewerRelease()
585 {
586 $this->assertFalse($this->matchCondition->match('[compatVersion = 15.0]'));
587 }
588
589 /**
590 * Tests whether the generic fetching of variables works with the namespace 'GP'.
591 *
592 * @test
593 */
594 public function genericGetVariablesSucceedsWithNamespaceGP()
595 {
596 $_GET = ['testGet' => 'getTest'];
597 $_POST = ['testPost' => 'postTest'];
598 $this->assertTrue($this->matchCondition->match('[globalString = GP:testGet = getTest]'));
599 $this->assertTrue($this->matchCondition->match('[globalString = GP:testPost = postTest]'));
600 }
601
602 /**
603 * Tests whether the generic fetching of variables works with the namespace 'TSFE'.
604 *
605 * @test
606 */
607 public function genericGetVariablesSucceedsWithNamespaceTSFE()
608 {
609 $GLOBALS['TSFE']->id = 1234567;
610 $GLOBALS['TSFE']->testSimpleObject = new \stdClass();
611 $GLOBALS['TSFE']->testSimpleObject->testSimpleVariable = 'testValue';
612
613 $prophecy = $this->prophesize(FrontendUserAuthentication::class);
614 $prophecy->getSessionData(Argument::exact('foo'))->willReturn(['bar' => 1234567]);
615 $GLOBALS['TSFE']->fe_user = $prophecy->reveal();
616
617 $this->assertTrue($this->matchCondition->match('[globalString = TSFE:id = 1234567]'));
618 $this->assertTrue($this->matchCondition->match('[globalString = TSFE:testSimpleObject|testSimpleVariable = testValue]'));
619 $this->assertTrue($this->matchCondition->match('[globalString = TSFE:fe_user|sesData|foo|bar = 1234567]'));
620 }
621
622 /**
623 * Tests whether the generic fetching of variables works with the namespace 'ENV'.
624 *
625 * @test
626 */
627 public function genericGetVariablesSucceedsWithNamespaceENV()
628 {
629 $testKey = $this->getUniqueId('test');
630 putenv($testKey . '=testValue');
631 $this->assertTrue($this->matchCondition->match('[globalString = ENV:' . $testKey . ' = testValue]'));
632 }
633
634 /**
635 * Tests whether the generic fetching of variables works with the namespace 'IENV'.
636 *
637 * @test
638 */
639 public function genericGetVariablesSucceedsWithNamespaceIENV()
640 {
641 $_SERVER['HTTP_HOST'] = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') . ':1234567';
642 $this->assertTrue($this->matchCondition->match('[globalString = IENV:TYPO3_PORT = 1234567]'));
643 }
644
645 /**
646 * Tests whether the generic fetching of variables works with any global namespace.
647 *
648 * @test
649 */
650 public function genericGetVariablesSucceedsWithAnyGlobalNamespace()
651 {
652 $GLOBALS[$this->testGlobalNamespace] = [
653 'first' => 'testFirst',
654 'second' => ['third' => 'testThird']
655 ];
656 $this->assertTrue($this->matchCondition->match('[globalString = ' . $this->testGlobalNamespace . '|first = testFirst]'));
657 $this->assertTrue($this->matchCondition->match('[globalString = ' . $this->testGlobalNamespace . '|second|third = testThird]'));
658 }
659
660 /**
661 * @test
662 */
663 public function matchThrowsExceptionIfConditionClassDoesNotInheritFromAbstractCondition()
664 {
665 $this->expectException(InvalidTypoScriptConditionException::class);
666 $this->expectExceptionCode(1410286153);
667 $this->matchCondition->match('[stdClass = foo]');
668 }
669
670 /**
671 * @test
672 */
673 public function matchCallsTestConditionAndHandsOverParameters()
674 {
675 $this->expectException(TestConditionException::class);
676 $this->expectExceptionCode(1411581139);
677 $this->matchCondition->match('[TYPO3\\CMS\\Frontend\\Tests\\Unit\\Configuration\\TypoScript\\ConditionMatching\\Fixtures\\TestCondition = 7, != 6]');
678 }
679 }