Fixed bug #14079: Running the unit tests floods the deprecation log
[Packages/TYPO3.CMS.git] / tests / t3lib / matchcondition / t3lib_matchcondition_frontend_testcase.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Oliver Hader <oliver@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * Testcase for class t3lib_matchCondition_frontend.
28 *
29 * @author Oliver Hader <oliver@typo3.org>
30 * @package TYPO3
31 * @subpackage t3lib
32 */
33 class t3lib_matchCondition_frontend_testcase extends tx_phpunit_testcase {
34 /**
35 * @var array
36 */
37 private $backupGlobalVariables;
38
39 /**
40 * @var array
41 */
42 private $rootline;
43
44 /**
45 * @var t3lib_matchCondition
46 */
47 private $matchCondition;
48
49 public function setUp() {
50 $this->backupGlobalVariables = array(
51 '_ENV' => $_ENV,
52 '_GET' => $_GET,
53 '_POST' => $_POST,
54 '_SERVER' => $_SERVER,
55 'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
56 'T3_VAR' => $GLOBALS['T3_VAR'],
57 );
58
59 $this->testGlobalNamespace = uniqid('TEST');
60 $GLOBALS[$this->testGlobalNamespace] = array();
61
62 $this->setUpTSFE();
63 $this->matchCondition = t3lib_div::makeInstance('t3lib_matchCondition_frontend');
64 }
65
66 public function tearDown() {
67 foreach ($this->backupGlobalVariables as $key => $data) {
68 $GLOBALS[$key] = $data;
69 }
70
71 unset($this->matchCondition);
72 unset($this->backupGlobalVariables);
73 unset($GLOBALS[$this->testGlobalNamespace]);
74 }
75
76 private function setUpTSFE() {
77 $this->rootline = array(
78 2 => array('uid' => 121, 'pid' => 111),
79 1 => array('uid' => 111, 'pid' => 101,),
80 0 => array('uid' => 101, 'pid' => 0,),
81 );
82
83 $GLOBALS['TSFE'] = $this->getMock('tslib_fe', array(), array(), '', FALSE);
84 $GLOBALS['TSFE']->tmpl = $this->getMock('t3lib_TStemplate');
85 }
86
87 /**
88 * Tests whether a faulty expression fails.
89 * @test
90 */
91 public function simulateDisabledMatchAllConditionsFailsOnFaultyExpression() {
92 $this->matchCondition->matchAll = false;
93 $this->assertFalse($this->matchCondition->match('[nullCondition = This expression would return false in general]'));
94 }
95
96 /**
97 * Tests whether simulating positive matches for all conditions succeeds.
98 * @test
99 */
100 public function simulateEnabledMatchAllConditionsSucceeds() {
101 $this->matchCondition->setSimulateMatchResult(true);
102 $this->assertTrue($this->matchCondition->match('[nullCondition = This expression would return false in general]'));
103 }
104
105 /**
106 * Tests whether simulating positive matches for specific conditions succeeds.
107 * @test
108 */
109 public function simulateEnabledMatchSpecificConditionsSucceeds() {
110 $testCondition = '[' . uniqid('test') . ' = Any condition to simulate a positive match]';
111 $this->matchCondition->setSimulateMatchConditions(array($testCondition));
112 $this->assertTrue($this->matchCondition->match($testCondition));
113 }
114
115 /**
116 * Tests whether a condition matches Internet Explorer 7 on Windows.
117 *
118 * @return void
119 * @test
120 */
121 public function conditionMatchesInternetExplorer7Windows() {
122 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)';
123 $result = $this->matchCondition->match('[browser = msie] && [version = 7] && [system = winNT]');
124 $this->assertTrue($result);
125 }
126
127 /**
128 * Tests whether a condition does not match Internet Explorer 7 on Windows.
129 *
130 * @return void
131 * @test
132 */
133 public function conditionDoesNotMatchInternetExplorer7Windows() {
134 $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.25 (Windows NT 6.0; U; en)';
135 $result = $this->matchCondition->match('[browser = msie] && [version = 7] && [system = winNT]');
136 $this->assertFalse($result);
137 }
138
139 /**
140 * Tests whether a device type condition matches a crawler.
141 * @test
142 */
143 public function deviceConditionMatchesRobot() {
144 $_SERVER['HTTP_USER_AGENT'] = 'Googlebot/2.1 (+http://www.google.com/bot.html)';
145 $result = $this->matchCondition->match('[device = robot]');
146 $this->assertTrue($result);
147 }
148
149 /**
150 * Tests whether a device type condition does not match a crawler.
151 * @test
152 */
153 public function deviceConditionDoesNotMatchRobot() {
154 $_SERVER['HTTP_USER_AGENT'] = md5('Some strange user agent');
155 $result = $this->matchCondition->match('[device = robot]');
156 $this->assertFalse($result);
157 }
158
159 /**
160 * Tests whether the browserInfo hook is called.
161 *
162 * @return void
163 * @test
164 */
165 public function deprecatedBrowserInfoHookIsCalled() {
166 $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = FALSE;
167
168 $classRef = uniqid('tx_browserInfoHook');
169 $browserInfoHookMock = $this->getMock($classRef, array('browserInfo'));
170 $browserInfoHookMock->expects($this->atLeastOnce())->method('browserInfo');
171
172 $GLOBALS['T3_VAR']['getUserObj'][$classRef] = $browserInfoHookMock;
173 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][$classRef] = $classRef;
174
175 $this->matchCondition->__construct();
176 $this->matchCondition->match('[browser = msie] && [version = 7] && [system = winNT]');
177 }
178
179 /**
180 * Tests whether the whichDevice hook is called.
181 *
182 * @return void
183 * @test
184 */
185 public function deprecatedWhichDeviceHookIsCalled() {
186 $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = FALSE;
187
188 $classRef = uniqid('tx_whichDeviceHook');
189 $whichDeviceHookMock = $this->getMock($classRef, array('whichDevice'));
190 $whichDeviceHookMock->expects($this->atLeastOnce())->method('whichDevice');
191
192 $GLOBALS['T3_VAR']['getUserObj'][$classRef] = $whichDeviceHookMock;
193 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][$classRef] = $classRef;
194
195 $this->matchCondition->__construct();
196 $this->matchCondition->match('[device = robot]');
197 }
198
199 /**
200 * Tests whether the language comparison matches.
201 * @test
202 */
203 public function languageConditionMatchesSingleLanguageExpression() {
204 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
205 $this->assertTrue($this->matchCondition->match('[language = *de*]'));
206 $this->assertTrue($this->matchCondition->match('[language = *de-de*]'));
207 }
208
209 /**
210 * Tests whether the language comparison matches.
211 * @test
212 */
213 public function languageConditionMatchesMultipleLanguagesExpression() {
214 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
215 $this->assertTrue($this->matchCondition->match('[language = *en*,*de*]'));
216 $this->assertTrue($this->matchCondition->match('[language = *en-us*,*de-de*]'));
217 }
218
219 /**
220 * Tests whether the language comparison matches.
221 * @test
222 */
223 public function languageConditionMatchesCompleteLanguagesExpression() {
224 $this->markTestSkipped('This comparison seems to be incomplete in t3lib_matchCondition.');
225
226 $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
227 $this->assertTrue($this->matchCondition->match('[language = de-de,de;q=0.8]'));
228 }
229
230 /**
231 * Tests whether usergroup comparison matches.
232 * @test
233 */
234 public function usergroupConditionMatchesSingleGroupId() {
235 $GLOBALS['TSFE']->gr_list = '13,14,15';
236 $this->assertTrue($this->matchCondition->match('[usergroup = 13]'));
237 }
238
239 /**
240 * Tests whether usergroup comparison matches.
241 * @test
242 */
243 public function usergroupConditionMatchesMultipleUserGroupId() {
244 $GLOBALS['TSFE']->gr_list = '13,14,15';
245 $this->assertTrue($this->matchCondition->match('[usergroup = 999,15,14,13]'));
246 }
247
248 /**
249 * Tests whether usergroup comparison matches.
250 * @test
251 */
252 public function usergroupConditionDoesNotMatchDefaulUserGroupIds() {
253 $GLOBALS['TSFE']->gr_list = '0,-1';
254 $this->assertFalse($this->matchCondition->match('[usergroup = 0,-1]'));
255 }
256
257 /**
258 * Tests whether user comparison matches.
259 * @test
260 */
261 public function loginUserConditionMatchesAnyLoggedInUser() {
262 $GLOBALS['TSFE']->loginUser = TRUE;
263 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
264 $this->assertTrue($this->matchCondition->match('[loginUser = *]'));
265 }
266
267 /**
268 * Tests whether user comparison matches.
269 * @test
270 */
271 public function loginUserConditionMatchesSingleLoggedInUser() {
272 $GLOBALS['TSFE']->loginUser = TRUE;
273 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
274 $this->assertTrue($this->matchCondition->match('[loginUser = 13]'));
275 }
276
277 /**
278 * Tests whether user comparison matches.
279 * @test
280 */
281 public function loginUserConditionMatchesMultipleLoggedInUsers() {
282 $GLOBALS['TSFE']->loginUser = TRUE;
283 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
284 $this->assertTrue($this->matchCondition->match('[loginUser = 999,13]'));
285 }
286
287 /**
288 * Tests whether user comparison matches.
289 * @test
290 */
291 public function loginUserConditionDoesNotMatchIfNotUserIsLoggedId() {
292 $GLOBALS['TSFE']->loginUser = FALSE;
293 $GLOBALS['TSFE']->fe_user->user['uid'] = 13;
294 $this->assertFalse($this->matchCondition->match('[loginUser = *]'));
295 $this->assertFalse($this->matchCondition->match('[loginUser = 13]'));
296 }
297
298 /**
299 * Tests whether numerical comparison matches.
300 * @test
301 */
302 public function globalVarConditionMatchesOnEqualExpression() {
303 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 = 10]'));
304 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 = 10.1]'));
305
306 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 == 10]'));
307 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 == 10.1]'));
308 }
309
310 /**
311 * Tests whether numerical comparison matches.
312 * @test
313 */
314 public function globalVarConditionMatchesOnNotEqualExpression() {
315 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 != 20]'));
316 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 != 10.2]'));
317 }
318
319 /**
320 * Tests whether numerical comparison matches.
321 * @test
322 */
323 public function globalVarConditionMatchesOnLowerThanExpression() {
324 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 < 20]'));
325 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 < 10.2]'));
326 }
327
328 /**
329 * Tests whether numerical comparison matches.
330 * @test
331 */
332 public function globalVarConditionMatchesOnLowerThanOrEqualExpression() {
333 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 <= 10]'));
334 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 <= 20]'));
335
336 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 <= 10.1]'));
337 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 <= 10.2]'));
338 }
339
340 /**
341 * Tests whether numerical comparison matches.
342 * @test
343 */
344 public function globalVarConditionMatchesOnGreaterThanExpression() {
345 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20 > 10]'));
346 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.2 > 10.1]'));
347 }
348
349 /**
350 * Tests whether numerical comparison matches.
351 * @test
352 */
353 public function globalVarConditionMatchesOnGreaterThanOrEqualExpression() {
354 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10 >= 10]'));
355 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:20 >= 10]'));
356
357 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.1 >= 10.1]'));
358 $this->assertTrue($this->matchCondition->match('[globalVar = LIT:10.2 >= 10.1]'));
359 }
360
361 /**
362 * Tests whether numerical comparison matches.
363 * @test
364 */
365 public function globalVarConditionMatchesOnEmptyExpressionWithNoValueSet() {
366 $testKey = uniqid('test');
367 $this->assertTrue($this->matchCondition->match('[globalVar = GP:' . $testKey . '=]'));
368 $this->assertTrue($this->matchCondition->match('[globalVar = GP:' . $testKey . ' = ]'));
369 }
370
371 /**
372 * Tests whether numerical comparison matches.
373 * @test
374 */
375 public function globalVarConditionDoesNotMatchOnEmptyExpressionWithValueSetToZero() {
376 $testKey = uniqid('test');
377
378 $_GET = array();
379 $_POST = array($testKey => 0);
380
381 $this->assertFalse($this->matchCondition->match('[globalVar = GP:' . $testKey . '=]'));
382 $this->assertFalse($this->matchCondition->match('[globalVar = GP:' . $testKey . ' = ]'));
383 }
384
385 /**
386 * Tests whether string comparison matches.
387 * @test
388 */
389 public function globalStringConditionMatchesOnEqualExpression() {
390 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3.Test.Condition]'));
391 $this->assertFalse($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3]'));
392 }
393
394 /**
395 * Tests whether string comparison matches.
396 * @test
397 */
398 public function globalStringConditionMatchesWildcardExpression() {
399 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3?Test?Condition]'));
400 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3.T*t.Condition]'));
401 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = TYPO3?T*t?Condition]'));
402 }
403
404 /**
405 * Tests whether string comparison matches.
406 * @test
407 */
408 public function globalStringConditionMatchesRegularExpression() {
409 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = /^[A-Za-z3.]+$/]'));
410 $this->assertTrue($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = /^TYPO3\..+Condition$/]'));
411 $this->assertFalse($this->matchCondition->match('[globalString = LIT:TYPO3.Test.Condition = /^FALSE/]'));
412 }
413
414 /**
415 * Tests whether string comparison matches.
416 * @test
417 */
418 public function globalStringConditionMatchesEmptyRegularExpression() {
419 $testKey = uniqid('test');
420 $_SERVER[$testKey] = '';
421 $this->assertTrue($this->matchCondition->match('[globalString = _SERVER|' . $testKey . ' = /^$/]'));
422 }
423
424 /**
425 * Tests whether treeLevel comparison matches.
426 * @test
427 */
428 public function treeLevelConditionMatchesSingleValue() {
429 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
430 $this->assertTrue($this->matchCondition->match('[treeLevel = 2]'));
431 }
432
433 /**
434 * Tests whether treeLevel comparison matches.
435 * @test
436 */
437 public function treeLevelConditionMatchesMultipleValues() {
438 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
439 $this->assertTrue($this->matchCondition->match('[treeLevel = 999,998,2]'));
440 }
441
442 /**
443 * Tests whether treeLevel comparison matches.
444 * @test
445 */
446 public function treeLevelConditionDoesNotMatchFaultyValue() {
447 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
448 $this->assertFalse($this->matchCondition->match('[treeLevel = 999]'));
449 }
450
451 /**
452 * Tests whether a page Id is found in the previous rootline entries.
453 * @test
454 */
455 public function PIDupinRootlineConditionMatchesSinglePageIdInRootline() {
456 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
457 $GLOBALS['TSFE']->id = 121;
458 $this->assertTrue($this->matchCondition->match('[PIDupinRootline = 111]'));
459 }
460
461 /**
462 * Tests whether a page Id is found in the previous rootline entries.
463 * @test
464 */
465 public function PIDupinRootlineConditionMatchesMultiplePageIdsInRootline() {
466 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
467 $GLOBALS['TSFE']->id = 121;
468 $this->assertTrue($this->matchCondition->match('[PIDupinRootline = 999,111,101]'));
469 }
470
471 /**
472 * Tests whether a page Id is found in the previous rootline entries.
473 * @test
474 */
475 public function PIDupinRootlineConditionDoesNotMatchPageIdNotInRootline() {
476 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
477 $GLOBALS['TSFE']->id = 121;
478 $this->assertFalse($this->matchCondition->match('[PIDupinRootline = 999]'));
479 }
480
481 /**
482 * Tests whether a page Id is found in the previous rootline entries.
483 * @test
484 */
485 public function PIDupinRootlineConditionDoesNotMatchLastPageIdInRootline() {
486 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
487 $GLOBALS['TSFE']->id = 121;
488 $this->assertFalse($this->matchCondition->match('[PIDupinRootline = 121]'));
489 }
490
491 /**
492 * Tests whether a page Id is found in all rootline entries.
493 * @test
494 */
495 public function PIDinRootlineConditionMatchesSinglePageIdInRootline() {
496 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
497 $GLOBALS['TSFE']->id = 121;
498 $this->assertTrue($this->matchCondition->match('[PIDinRootline = 111]'));
499 }
500
501 /**
502 * Tests whether a page Id is found in all rootline entries.
503 * @test
504 */
505 public function PIDinRootlineConditionMatchesMultiplePageIdsInRootline() {
506 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
507 $GLOBALS['TSFE']->id = 121;
508 $this->assertTrue($this->matchCondition->match('[PIDinRootline = 999,111,101]'));
509 }
510
511 /**
512 * Tests whether a page Id is found in all rootline entries.
513 * @test
514 */
515 public function PIDinRootlineConditionMatchesLastPageIdInRootline() {
516 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
517 $GLOBALS['TSFE']->id = 121;
518 $this->assertTrue($this->matchCondition->match('[PIDinRootline = 121]'));
519 }
520
521 /**
522 * Tests whether a page Id is found in all rootline entries.
523 * @test
524 */
525 public function PIDinRootlineConditionDoesNotMatchPageIdNotInRootline() {
526 $GLOBALS['TSFE']->tmpl->rootLine = $this->rootline;
527 $GLOBALS['TSFE']->id = 121;
528 $this->assertFalse($this->matchCondition->match('[PIDinRootline = 999]'));
529 }
530
531 /**
532 * Tests whether the compatibility version can be evaluated.
533 * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
534 * @test
535 */
536 public function compatVersionConditionMatchesOlderRelease() {
537 $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
538 $this->assertTrue($this->matchCondition->match('[compatVersion = 4.0]'));
539 }
540
541 /**
542 * Tests whether the compatibility version can be evaluated.
543 * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
544 * @test
545 */
546 public function compatVersionConditionMatchesSameRelease() {
547 $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
548 $this->assertTrue($this->matchCondition->match('[compatVersion = 4.9]'));
549 }
550
551 /**
552 * Tests whether the compatibility version can be evaluated.
553 * (e.g. 4.9 is compatible to 4.0 but not to 5.0)
554 * @test
555 */
556 public function compatVersionConditionDoesNotMatchNewerRelease() {
557 $GLOBALS['TYPO3_CONF_VARS']['SYS']['compat_version'] = '4.9';
558 $this->assertFalse($this->matchCondition->match('[compatVersion = 5.0]'));
559 }
560
561 /**
562 * Tests whether the generic fetching of variables works with the namespace 'GP'.
563 * @test
564 */
565 public function genericGetVariablesSucceedsWithNamespaceGP() {
566 $_GET = array('testGet' => 'getTest');
567 $_POST = array('testPost' => 'postTest');
568
569 $this->assertTrue($this->matchCondition->match('[globalString = GP:testGet = getTest]'));
570 $this->assertTrue($this->matchCondition->match('[globalString = GP:testPost = postTest]'));
571 }
572
573 /**
574 * Tests whether the generic fetching of variables works with the namespace 'TSFE'.
575 * @test
576 */
577 public function genericGetVariablesSucceedsWithNamespaceTSFE() {
578 $GLOBALS['TSFE']->id = 1234567;
579 $GLOBALS['TSFE']->testSimpleObject = new stdClass();
580 $GLOBALS['TSFE']->testSimpleObject->testSimpleVariable = 'testValue';
581
582 $this->assertTrue($this->matchCondition->match('[globalString = TSFE:id = 1234567]'));
583 $this->assertTrue($this->matchCondition->match('[globalString = TSFE:testSimpleObject|testSimpleVariable = testValue]'));
584 }
585
586 /**
587 * Tests whether the generic fetching of variables works with the namespace 'ENV'.
588 * @test
589 */
590 public function genericGetVariablesSucceedsWithNamespaceENV() {
591 $testKey = uniqid('test');
592 putenv($testKey .'=testValue');
593
594 $this->assertTrue($this->matchCondition->match('[globalString = ENV:' . $testKey . ' = testValue]'));
595 }
596
597 /**
598 * Tests whether the generic fetching of variables works with the namespace 'IENV'.
599 * @test
600 */
601 public function genericGetVariablesSucceedsWithNamespaceIENV() {
602 $_SERVER['HTTP_HOST'] = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY') . ':1234567';
603 $this->assertTrue($this->matchCondition->match('[globalString = IENV:TYPO3_PORT = 1234567]'));
604 }
605
606 /**
607 * Tests whether the generic fetching of variables works with any global namespace.
608 * @test
609 */
610 public function genericGetVariablesSucceedsWithAnyGlobalNamespace() {
611 $GLOBALS[$this->testGlobalNamespace] = array(
612 'first' => 'testFirst',
613 'second' => array('third' => 'testThird'),
614 );
615
616 $this->assertTrue($this->matchCondition->match(
617 '[globalString = ' . $this->testGlobalNamespace . '|first = testFirst]'
618 ));
619 $this->assertTrue($this->matchCondition->match(
620 '[globalString = ' . $this->testGlobalNamespace . '|second|third = testThird]'
621 ));
622 }
623 }
624 ?>