Fixed bug #17490: After introducing the locking in #17289 no CSRF token will ever...
[Packages/TYPO3.CMS.git] / tests / t3lib / t3lib_pagerendererTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Steffen Kamper (info@sk-typo3.de)
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 the t3lib_PageRenderer class in the TYPO3 core.
28 *
29 * @package TYPO3
30 * @subpackage t3lib
31 *
32 * @author Steffen Kamper (info@sk-typo3.de)
33 */
34 class t3lib_PageRendererTest extends tx_phpunit_testcase {
35
36 /**
37 * Enable backup of global and system variables
38 *
39 * @var boolean
40 */
41 protected $backupGlobals = TRUE;
42
43 /**
44 * Exclude TYPO3_DB from backup/ restore of $GLOBALS
45 * because resource types cannot be handled during serializing
46 *
47 * @var array
48 */
49 protected $backupGlobalsBlacklist = array('TYPO3_DB');
50
51 /**
52 * @var t3lib_PageRenderer
53 */
54 private $fixture;
55
56 public function setUp() {
57 $this->fixture = new t3lib_PageRenderer();
58 $this->fixture->setCharSet($GLOBALS['LANG']->charSet);
59 }
60
61 public function tearDown() {
62 unset(
63 $this->fixture
64 );
65 }
66
67
68 //////////////////////////////////////
69 // Tests for the basic functionality
70 //////////////////////////////////////
71
72 /**
73 * @test
74 */
75 public function fixtureCanBeCreated() {
76 $this->assertTrue(
77 $this->fixture instanceof t3lib_PageRenderer
78 );
79 }
80
81 //////////////////////
82 // test functions
83 //////////////////////
84
85 /**
86 * test set xml prolog and doctype
87 *
88 */
89 public function testSetXmlPrologAndDocType() {
90
91 $expectedReturnValue = '<?xml version="1.0" encoding="utf-8" ?>';
92 $this->fixture->setXmlPrologAndDocType('<?xml version="1.0" encoding="utf-8" ?>');
93 $out = $this->fixture->render();
94
95 $this->assertContains(
96 $expectedReturnValue,
97 $out
98 );
99 }
100
101 /**
102 * test set title
103 *
104 */
105 public function testSetTitle() {
106
107 $expectedReturnValue = '<title>This is the title</title>';
108 $this->fixture->setTitle('This is the title');
109 $out = $this->fixture->render();
110
111 $this->assertContains(
112 $expectedReturnValue,
113 $out
114 );
115 }
116
117 /**
118 * test set charset
119 *
120 */
121 public function testSetCharset() {
122
123 $expectedReturnValue = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
124 $this->fixture->setCharset('utf-8');
125 $out = $this->fixture->render();
126
127 $this->assertContains(
128 $expectedReturnValue,
129 $out
130 );
131 }
132
133 /**
134 * test set favicon
135 *
136 */
137 public function testSetFavIcon() {
138
139 $expectedReturnValue1 = '<link rel="shortcut icon" href="http://google.com/favicon.ico" />';
140 $expectedReturnValue2 = '<link rel="icon" href="http://google.com/favicon.ico" />';
141 $this->fixture->setFavIcon('http://google.com/favicon.ico');
142 $out = $this->fixture->render();
143
144 $this->assertContains(
145 $expectedReturnValue1,
146 $out
147 );
148 $this->assertContains(
149 $expectedReturnValue2,
150 $out
151 );
152
153 }
154
155 /**
156 * test set baseUrl
157 *
158 */
159 public function testSetBaseUrl() {
160
161 $expectedReturnValue = '<base href="http://ggogle.com/" />';
162 $this->fixture->setBaseUrl('http://ggogle.com/');
163 $out = $this->fixture->render();
164
165 $this->assertContains(
166 $expectedReturnValue,
167 $out
168 );
169 }
170
171 /**
172 * test add meta tag
173 *
174 */
175 public function testAddMetaTag() {
176
177 $expectedReturnValue = '<meta name="author" content="Anna Lyse">';
178 $this->fixture->addMetaTag('<meta name="author" content="Anna Lyse">');
179 $out = $this->fixture->render();
180
181 $this->assertContains(
182 $expectedReturnValue,
183 $out
184 );
185 }
186
187 /**
188 * test add inline comment
189 *
190 */
191 public function testAddInlineComment() {
192
193 $expectedReturnValue = 'this is an inline comment written by unit test';
194 $this->fixture->addInlineComment('this is an inline comment written by unit test');
195 $out = $this->fixture->render();
196
197 $this->assertContains(
198 $expectedReturnValue,
199 $out
200 );
201 }
202
203 /**
204 * test add header data
205 *
206 */
207 public function testAddHeaderData() {
208
209 $expectedReturnValue = '<tag method="private" name="test" />';
210 $this->fixture->addHeaderData('<tag method="private" name="test" />');
211 $out = $this->fixture->render();
212
213 $this->assertContains(
214 $expectedReturnValue,
215 $out
216 );
217 }
218
219 /**
220 * test add footer data
221 *
222 */
223 public function testAddFooterData() {
224
225 $expectedReturnValue = '<tag method="private" name="test" />';
226 $this->fixture->addFooterData('<tag method="private" name="test" />');
227 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
228
229 $this->assertContains(
230 $expectedReturnValue,
231 $out
232 );
233 }
234
235 /**
236 * test add JS library file
237 *
238 */
239 public function testAddJsLibrary() {
240
241 $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
242 $this->fixture->addJsLibrary('test', 'fileadmin/test.js');
243 $out = $this->fixture->render();
244
245 $this->assertRegExp(
246 $expectedRegExp,
247 $out
248 );
249 }
250
251
252 /**
253 * test add JS footer library file
254 *
255 */
256 public function testAddJsFooterLibrary() {
257
258 $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
259 $this->fixture->addJsFooterLibrary('test', 'fileadmin/test.js');
260 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
261
262 $this->assertRegExp(
263 $expectedRegExp,
264 $out
265 );
266 }
267
268 /**
269 * test add JS file
270 *
271 */
272 public function testAddJsFile() {
273
274 $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
275 $this->fixture->addJsFile('fileadmin/test.js');
276 $out = $this->fixture->render();
277
278 $this->assertRegExp(
279 $expectedRegExp,
280 $out
281 );
282 }
283
284 /**
285 * test add JS file for footer
286 *
287 */
288 public function testAddJsFooterFile() {
289
290 $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
291 $this->fixture->addJsFooterFile('fileadmin/test.js');
292 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
293
294 $this->assertRegExp(
295 $expectedRegExp,
296 $out
297 );
298 }
299
300 /**
301 * test add JS inline
302 *
303 */
304 public function testAddJsInlineCode() {
305
306 $expectedReturnValue = 'var x = "testvar"';
307 $this->fixture->addJsInlineCode('test', 'var x = "testvar"');
308 $out = $this->fixture->render();
309
310 $this->assertContains(
311 $expectedReturnValue,
312 $out
313 );
314 }
315
316 /**
317 * test add JS inline for footer
318 *
319 */
320 public function testAddJsFooterInlineCode() {
321
322 $expectedReturnValue = 'var x = "testvar"';
323 $this->fixture->addJsFooterInlineCode('test', 'var x = "testvar"');
324 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
325
326 $this->assertContains(
327 $expectedReturnValue,
328 $out
329 );
330 }
331
332 /**
333 * test add JS handler
334 *
335 */
336 public function testAddExtOnReadyCode() {
337
338 $expectedReturnValue1 = 'Ext.onReady(function() {';
339 $expectedReturnValue2 = 'var x = "testvar";';
340 $this->fixture->loadExtJS();
341 $this->fixture->addExtOnReadyCode('var x = "testvar";');
342 $out = $this->fixture->render();
343
344 $this->assertContains(
345 $expectedReturnValue1,
346 $out
347 );
348
349 $this->assertContains(
350 $expectedReturnValue2,
351 $out
352 );
353
354 }
355
356 /**
357 * test add CSS file
358 *
359 */
360 public function testAddCssFile() {
361
362 $expectedReturnValue = '<link rel="stylesheet" type="text/css" href="fileadmin/test.css" media="all" />';
363 $this->fixture->addCssFile('fileadmin/test.css');
364 $out = $this->fixture->render();
365
366 $this->assertContains(
367 $expectedReturnValue,
368 $out
369 );
370 }
371
372 /**
373 * test add CSS inline
374 *
375 */
376 public function testAddCssInlineBlock() {
377
378 $expectedReturnValue = 'body {margin:20px;}';
379 $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}');
380 $out = $this->fixture->render();
381
382 $this->assertContains(
383 $expectedReturnValue,
384 $out
385 );
386 }
387
388 /**
389 * test add CSS inline and force on top
390 *
391 */
392 public function testAddCssInlineBlockForceOnTop() {
393
394 $expectedReturnValue = '/*general1*/' . LF . 'h1 {margin:20px;}' . LF . '/*general*/' . LF . 'body {margin:20px;}';
395 $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}');
396 $this->fixture->addCssInlineBlock('general1', 'h1 {margin:20px;}', NULL, TRUE);
397 $out = $this->fixture->render();
398
399 $this->assertContains(
400 $expectedReturnValue,
401 $out
402 );
403 }
404
405 /**
406 * test load prototype
407 *
408 */
409 public function testLoadPrototype() {
410
411 $expectedRegExp = '#<script src="contrib/prototype/prototype\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
412 $this->fixture->loadPrototype();
413 $out = $this->fixture->render();
414
415 $this->assertRegExp(
416 $expectedRegExp,
417 $out
418 );
419 }
420
421 /**
422 * test load Scriptaculous
423 *
424 */
425 public function testLoadScriptaculous() {
426 $this->fixture->loadScriptaculous('slider,controls');
427 $out = $this->fixture->render();
428
429 $this->assertContains(
430 '<script src="contrib/scriptaculous/scriptaculous.js" type="text/javascript"></script>',
431 $out
432 );
433 $this->assertContains(
434 '<script src="contrib/scriptaculous/effects.js" type="text/javascript"></script>',
435 $out
436 );
437 $this->assertContains(
438 '<script src="contrib/scriptaculous/controls.js" type="text/javascript"></script>',
439 $out
440 );
441 $this->assertContains(
442 '<script src="contrib/scriptaculous/slider.js" type="text/javascript"></script>',
443 $out
444 );
445 }
446
447 /**
448 * Tests whether scriptaculous is loaded correctly when compression is enabled.
449 *
450 * @test
451 */
452 public function isScriptaculousLoadedCompressedIfConfiguredAndClientIsCapable() {
453 $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
454 $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
455
456 $this->fixture->loadScriptaculous('slider,controls');
457 $this->fixture->enableCompressJavascript();
458 $out = $this->fixture->render();
459
460 $this->assertRegExp(
461 '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
462 $out
463 );
464 $this->assertRegExp(
465 '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
466 $out
467 );
468 $this->assertRegExp(
469 '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
470 $out
471 );
472 $this->assertRegExp(
473 '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
474 $out
475 );
476 }
477
478 /**
479 * Tests whether scriptaculous is correctly loaded, but without compression
480 * if the browser did not send the appropriate headers.
481 *
482 * @test
483 */
484 public function isScriptaculousNotLoadedCompressedIfClientCannotHandleCompression() {
485 $_SERVER['HTTP_ACCEPT_ENCODING'] = '';
486 $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
487
488 $this->fixture->loadScriptaculous('slider,controls');
489 $this->fixture->enableCompressJavascript();
490 $out = $this->fixture->render();
491
492 $this->assertRegExp(
493 '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#',
494 $out
495 );
496 $this->assertRegExp(
497 '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#',
498 $out
499 );
500 $this->assertRegExp(
501 '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#',
502 $out
503 );
504 $this->assertRegExp(
505 '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#',
506 $out
507 );
508 }
509
510 /**
511 * Tests whether scriptaculous is correctly loaded, but without compression
512 * if no compression is configured.
513 *
514 * @test
515 */
516 public function isScriptaculousNotLoadedCompressedIfCompressionIsNotConfigured() {
517 $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
518 $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '';
519
520 $this->fixture->loadScriptaculous('slider,controls');
521 $this->fixture->enableCompressJavascript();
522 $out = $this->fixture->render();
523
524 $this->assertRegExp(
525 '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#',
526 $out
527 );
528 $this->assertRegExp(
529 '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#',
530 $out
531 );
532 $this->assertRegExp(
533 '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#',
534 $out
535 );
536 $this->assertRegExp(
537 '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#',
538 $out
539 );
540 }
541
542 /**
543 * test load ExtJS
544 *
545 */
546 public function testLoadExtJS() {
547
548 $expectedRegExp = '#<script src="contrib/extjs/adapter/jquery/ext-jquery-adapter\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>' . LF . '<script src="contrib/extjs/ext-all\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#m';
549 $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
550 $out = $this->fixture->render();
551
552 $this->assertRegExp(
553 $expectedRegExp,
554 $out
555 );
556 }
557
558 /**
559 * test load ExtCore
560 *
561 */
562 public function testLoadExtCore() {
563
564 $expectedRegExp = '#<script src="contrib/extjs/ext-core\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
565 $this->fixture->loadExtCore();
566 $out = $this->fixture->render();
567
568 $this->assertRegExp(
569 $expectedRegExp,
570 $out
571 );
572 }
573
574 /**
575 * test enable ExtJsDebug
576 *
577 */
578 public function testEnableExtJsDebug() {
579
580 $expectedRegExp = '#<script src="contrib/extjs/ext-all-debug\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
581 $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
582 $this->fixture->enableExtJsDebug();
583 $out = $this->fixture->render();
584
585 $this->assertRegExp(
586 $expectedRegExp,
587 $out
588 );
589 }
590
591 /**
592 * test enable ExtCoreDebug
593 *
594 */
595 public function testEnableExtCoreDebug() {
596
597 $expectedRegExp = '#<script src="contrib/extjs/ext-core-debug\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
598 $this->fixture->loadExtCore();
599 $this->fixture->enableExtCoreDebug();
600 $out = $this->fixture->render();
601
602 $this->assertRegExp(
603 $expectedRegExp,
604 $out
605 );
606 }
607
608 /**
609 * test inline language label
610 *
611 */
612 public function testAddInlineLanguageLabel() {
613
614 $expectedReturnValue = 'TYPO3.lang = {"myKey":"myValue"}';
615 $this->fixture->loadExtJS();
616 $this->fixture->addInlineLanguageLabel('myKey', 'myValue');
617 $out = $this->fixture->enableMoveJsFromHeaderToFooter();
618 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
619
620 $this->assertContains(
621 $expectedReturnValue,
622 $out
623 );
624 }
625
626 /**
627 * test inline language label as array
628 *
629 */
630 public function testAddInlineLanguageLabelArray() {
631
632 $expectedReturnValue = 'TYPO3.lang = {"myKey1":"myValue1","myKey2":"myValue2"}';
633 $this->fixture->loadExtJS();
634 $this->fixture->addInlineLanguageLabelArray(array('myKey1' => 'myValue1', 'myKey2' => 'myValue2',));
635 $out = $this->fixture->enableMoveJsFromHeaderToFooter();
636 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
637
638 $this->assertContains(
639 $expectedReturnValue,
640 $out
641 );
642 }
643
644 /**
645 * test inline language label as array get merged
646 *
647 */
648 public function testAddInlineLanguageLabelArrayMerged() {
649
650 $expectedReturnValue = 'TYPO3.lang = {"myKey1":"myValue1","myKey2":"myValue2"}';
651 $this->fixture->loadExtJS();
652 $this->fixture->addInlineLanguageLabelArray(array('myKey1' => 'myValue1',));
653 $this->fixture->addInlineLanguageLabelArray(array('myKey2' => 'myValue2',));
654 $out = $this->fixture->enableMoveJsFromHeaderToFooter();
655 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
656
657 $this->assertContains(
658 $expectedReturnValue,
659 $out
660 );
661 }
662
663 /**
664 * test inline setting
665 *
666 */
667 public function testAddInlineSetting() {
668
669 $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey":"myValue"}};';
670 $this->fixture->loadExtJS();
671 $this->fixture->addInlineSetting('myApp', 'myKey', 'myValue');
672 $out = $this->fixture->enableMoveJsFromHeaderToFooter();
673 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
674
675 $this->assertContains(
676 $expectedReturnValue,
677 $out
678 );
679 }
680
681 /**
682 * test inline settings with array
683 *
684 */
685 public function testAddInlineSettingArray() {
686
687 $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey1":"myValue1","myKey2":"myValue2"}};';
688 $this->fixture->loadExtJS();
689 $this->fixture->addInlineSettingArray('myApp', array('myKey1' => 'myValue1', 'myKey2' => 'myValue2',));
690 $out = $this->fixture->enableMoveJsFromHeaderToFooter();
691 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
692
693 $this->assertContains(
694 $expectedReturnValue,
695 $out
696 );
697 }
698
699 /**
700 * test inline settings with array get merged
701 *
702 */
703 public function testAddInlineSettingArrayMerged() {
704
705 $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey1":"myValue1","myKey2":"myValue2"}};';
706 $this->fixture->loadExtJS();
707 $this->fixture->addInlineSettingArray('myApp', array('myKey1' => 'myValue1',));
708 $this->fixture->addInlineSettingArray('myApp', array('myKey2' => 'myValue2',));
709 $out = $this->fixture->enableMoveJsFromHeaderToFooter();
710 $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
711
712 $this->assertContains(
713 $expectedReturnValue,
714 $out
715 );
716 }
717
718 /**
719 * test add body content
720 *
721 */
722 public function testAddBodyContent() {
723 $expectedReturnValue = 'ABCDE';
724 $this->fixture->addBodyContent('A');
725 $this->fixture->addBodyContent('B');
726 $this->fixture->addBodyContent('C');
727 $this->fixture->addBodyContent('D');
728 $this->fixture->addBodyContent('E');
729
730 $out = $this->fixture->getBodyContent();
731 $this->assertEquals(
732 $expectedReturnValue,
733 $out
734 );
735 }
736
737
738 /**
739 * test set body content
740 *
741 */
742 public function testSetBodyContent() {
743 $expectedReturnValue = 'ABCDE';
744 $this->fixture->setBodyContent('ABCDE');
745
746 $out = $this->fixture->getBodyContent();
747 $this->assertEquals(
748 $expectedReturnValue,
749 $out
750 );
751
752 $out = $this->fixture->render();
753
754 $this->assertContains(
755 $expectedReturnValue,
756 $out
757 );
758 }
759
760 /**
761 * Tests whether labels are delivered in a non-UTF-8 context.
762 * (background: json_encode() requires UTF-8 to work properly)
763 *
764 * @test
765 */
766 public function isInlineLanguageLabelDeliveredWithNonUTF8() {
767 $testPrefix = uniqid('test');
768 $this->fixture->loadExtCore();
769 $this->fixture->setCharSet('iso-8859-1');
770 $this->fixture->addInlineLanguageLabel($testPrefix, $testPrefix . "_\xd8");
771
772 $out = $this->fixture->render();
773
774 $this->assertContains($testPrefix . '_\\u00d8', $out);
775 }
776
777 /**
778 * Tests the addInlineLanguageLabelFile() method.
779 *
780 * @test
781 * @expectedException RuntimeException
782 */
783 public function areInlineLanguageLabelsNotProcessable() {
784 $this->fixture->setLanguage(NULL);
785 $this->fixture->addInlineLanguageLabelFile(
786 'EXT:lang/locallang_core.xml'
787 );
788 $out = $this->fixture->render();
789 }
790
791 /**
792 * Tests the addInlineLanguageLabelFile() method.
793 *
794 * @test
795 */
796 public function areInlineLanguageLabelsPassed() {
797 $this->fixture->setLanguage($GLOBALS['LANG']->lang);
798 $this->fixture->addInlineLanguageLabelFile(
799 'EXT:lang/locallang_core.xml'
800 );
801
802 $out = $this->fixture->render();
803
804 $this->assertContains('labels.beUser', $out);
805 $this->assertContains('labels.feUser', $out);
806 }
807
808 /**
809 * Tests the addInlineLanguageLabelFile() method.
810 *
811 * @test
812 */
813 public function areInlineLanguageLabelsEmptyOnNonExistingFile() {
814 $this->fixture->addInlineLanguageLabelFile(
815 ''
816 );
817
818 $inlineLanguageLabelFiles = $this->fixture->getInlineLanguageLabelFiles();
819 $this->assertEquals(array(), $inlineLanguageLabelFiles);
820 }
821
822 /**
823 * Tests the addInlineLanguageLabelFile() method.
824 *
825 * @test
826 */
827 public function areInlineLanguageLabelsSelected() {
828 $this->fixture->setLanguage($GLOBALS['LANG']->lang);
829 $this->fixture->addInlineLanguageLabelFile(
830 'EXT:lang/locallang_core.xml',
831 'labels.'
832 );
833
834 $out = $this->fixture->render();
835 $this->assertContains('labels.beUser', $out);
836 $this->assertContains('labels.feUser', $out);
837 }
838
839 /**
840 * Tests the addInlineLanguageLabelFile() method.
841 *
842 * @test
843 */
844 public function areInlineLanguageLabelsSelectedAndStripped() {
845 $this->fixture->setLanguage($GLOBALS['LANG']->lang);
846 $this->fixture->addInlineLanguageLabelFile(
847 'EXT:lang/locallang_core.xml',
848 'labels.',
849 'lock'
850 );
851
852 $out = $this->fixture->render();
853
854 $this->assertContains('edRecord', $out);
855 $this->assertContains('edRecord_content', $out);
856 $this->assertContains('edRecordUser', $out);
857 }
858 }
859 ?>