TYPO3 API  SVNRelease
t3lib_pagerendererTest.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 * Copyright notice
00004 *
00005 * (c) 2009-2011 Steffen Kamper (info@sk-typo3.de)
00006 * All rights reserved
00007 *
00008 * This script is part of the TYPO3 project. The TYPO3 project is
00009 * free software; you can redistribute it and/or modify
00010 * it under the terms of the GNU General Public License as published by
00011 * the Free Software Foundation; either version 2 of the License or
00012 * (at your option) any later version.
00013 *
00014 * The GNU General Public License can be found at
00015 * http://www.gnu.org/copyleft/gpl.html.
00016 *
00017 * This script is distributed in the hope that it will be useful
00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 * GNU General Public License for more details.
00021 *
00022 * This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 
00026 /**
00027  * Testcase for the t3lib_PageRenderer class in the TYPO3 core.
00028  *
00029  * @package TYPO3
00030  * @subpackage t3lib
00031  *
00032  * @author Steffen Kamper (info@sk-typo3.de)
00033  */
00034 class t3lib_PageRendererTest extends tx_phpunit_testcase {
00035 
00036     /**
00037      * Enable backup of global and system variables
00038      *
00039      * @var boolean
00040      */
00041     protected $backupGlobals = TRUE;
00042 
00043     /**
00044      * Exclude TYPO3_DB from backup/ restore of $GLOBALS
00045      * because resource types cannot be handled during serializing
00046      *
00047      * @var array
00048      */
00049     protected $backupGlobalsBlacklist = array('TYPO3_DB');
00050 
00051     /**
00052      * @var t3lib_PageRenderer
00053      */
00054     private $fixture;
00055 
00056     public function setUp() {
00057         $this->fixture = new t3lib_PageRenderer();
00058         $this->fixture->setCharSet($GLOBALS['LANG']->charSet);
00059     }
00060 
00061     public function tearDown() {
00062         unset(
00063             $this->fixture
00064         );
00065     }
00066 
00067 
00068     //////////////////////////////////////
00069     // Tests for the basic functionality
00070     //////////////////////////////////////
00071 
00072     /**
00073      * @test
00074      */
00075     public function fixtureCanBeCreated() {
00076         $this->assertTrue(
00077             $this->fixture instanceof t3lib_PageRenderer
00078         );
00079     }
00080 
00081     //////////////////////
00082     // test functions
00083     //////////////////////
00084 
00085     /**
00086      * test set xml prolog and doctype
00087      *
00088      */
00089     public function testSetXmlPrologAndDocType() {
00090 
00091         $expectedReturnValue = '<?xml version="1.0" encoding="utf-8" ?>';
00092         $this->fixture->setXmlPrologAndDocType('<?xml version="1.0" encoding="utf-8" ?>');
00093         $out = $this->fixture->render();
00094 
00095         $this->assertContains(
00096             $expectedReturnValue,
00097             $out
00098         );
00099     }
00100 
00101     /**
00102      * test set title
00103      *
00104      */
00105     public function testSetTitle() {
00106 
00107         $expectedReturnValue = '<title>This is the title</title>';
00108         $this->fixture->setTitle('This is the title');
00109         $out = $this->fixture->render();
00110 
00111         $this->assertContains(
00112             $expectedReturnValue,
00113             $out
00114         );
00115     }
00116 
00117     /**
00118      * test set charset
00119      *
00120      */
00121     public function testSetCharset() {
00122 
00123         $expectedReturnValue = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
00124         $this->fixture->setCharset('utf-8');
00125         $out = $this->fixture->render();
00126 
00127         $this->assertContains(
00128             $expectedReturnValue,
00129             $out
00130         );
00131     }
00132 
00133     /**
00134      * test set favicon
00135      *
00136      */
00137     public function testSetFavIcon() {
00138 
00139         $expectedReturnValue1 = '<link rel="shortcut icon" href="http://google.com/favicon.ico" />';
00140         $expectedReturnValue2 = '<link rel="icon" href="http://google.com/favicon.ico" />';
00141         $this->fixture->setFavIcon('http://google.com/favicon.ico');
00142         $out = $this->fixture->render();
00143 
00144         $this->assertContains(
00145             $expectedReturnValue1,
00146             $out
00147         );
00148         $this->assertContains(
00149             $expectedReturnValue2,
00150             $out
00151         );
00152 
00153     }
00154 
00155     /**
00156      * test set baseUrl
00157      *
00158      */
00159     public function testSetBaseUrl() {
00160 
00161         $expectedReturnValue = '<base href="http://ggogle.com/" />';
00162         $this->fixture->setBaseUrl('http://ggogle.com/');
00163         $out = $this->fixture->render();
00164 
00165         $this->assertContains(
00166             $expectedReturnValue,
00167             $out
00168         );
00169     }
00170 
00171     /**
00172      * test add meta tag
00173      *
00174      */
00175     public function testAddMetaTag() {
00176 
00177         $expectedReturnValue = '<meta name="author" content="Anna Lyse">';
00178         $this->fixture->addMetaTag('<meta name="author" content="Anna Lyse">');
00179         $out = $this->fixture->render();
00180 
00181         $this->assertContains(
00182             $expectedReturnValue,
00183             $out
00184         );
00185     }
00186 
00187     /**
00188      * test add inline comment
00189      *
00190      */
00191     public function testAddInlineComment() {
00192 
00193         $expectedReturnValue = 'this is an inline comment written by unit test';
00194         $this->fixture->addInlineComment('this is an inline comment written by unit test');
00195         $out = $this->fixture->render();
00196 
00197         $this->assertContains(
00198             $expectedReturnValue,
00199             $out
00200         );
00201     }
00202 
00203     /**
00204      * test add header data
00205      *
00206      */
00207     public function testAddHeaderData() {
00208 
00209         $expectedReturnValue = '<tag method="private" name="test" />';
00210         $this->fixture->addHeaderData('<tag method="private" name="test" />');
00211         $out = $this->fixture->render();
00212 
00213         $this->assertContains(
00214             $expectedReturnValue,
00215             $out
00216         );
00217     }
00218 
00219     /**
00220      * test add footer data
00221      *
00222      */
00223     public function testAddFooterData() {
00224 
00225         $expectedReturnValue = '<tag method="private" name="test" />';
00226         $this->fixture->addFooterData('<tag method="private" name="test" />');
00227         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00228 
00229         $this->assertContains(
00230             $expectedReturnValue,
00231             $out
00232         );
00233     }
00234 
00235     /**
00236      * test add JS library file
00237      *
00238      */
00239     public function testAddJsLibrary() {
00240 
00241         $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00242         $this->fixture->addJsLibrary('test', 'fileadmin/test.js');
00243         $out = $this->fixture->render();
00244 
00245         $this->assertRegExp(
00246             $expectedRegExp,
00247             $out
00248         );
00249     }
00250 
00251 
00252     /**
00253      * test add JS footer library file
00254      *
00255      */
00256     public function testAddJsFooterLibrary() {
00257 
00258         $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00259         $this->fixture->addJsFooterLibrary('test', 'fileadmin/test.js');
00260         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00261 
00262         $this->assertRegExp(
00263             $expectedRegExp,
00264             $out
00265         );
00266     }
00267 
00268     /**
00269      * test add JS file
00270      *
00271      */
00272     public function testAddJsFile() {
00273 
00274         $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00275         $this->fixture->addJsFile('fileadmin/test.js');
00276         $out = $this->fixture->render();
00277 
00278         $this->assertRegExp(
00279             $expectedRegExp,
00280             $out
00281         );
00282     }
00283 
00284     /**
00285      * test add JS file for footer
00286      *
00287      */
00288     public function testAddJsFooterFile() {
00289 
00290         $expectedRegExp = '#<script src="fileadmin/test\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00291         $this->fixture->addJsFooterFile('fileadmin/test.js');
00292         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00293 
00294         $this->assertRegExp(
00295             $expectedRegExp,
00296             $out
00297         );
00298     }
00299 
00300     /**
00301      * test add JS inline
00302      *
00303      */
00304     public function testAddJsInlineCode() {
00305 
00306         $expectedReturnValue = 'var x = "testvar"';
00307         $this->fixture->addJsInlineCode('test', 'var x = "testvar"');
00308         $out = $this->fixture->render();
00309 
00310         $this->assertContains(
00311             $expectedReturnValue,
00312             $out
00313         );
00314     }
00315 
00316     /**
00317      * test add JS inline for footer
00318      *
00319      */
00320     public function testAddJsFooterInlineCode() {
00321 
00322         $expectedReturnValue = 'var x = "testvar"';
00323         $this->fixture->addJsFooterInlineCode('test', 'var x = "testvar"');
00324         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00325 
00326         $this->assertContains(
00327             $expectedReturnValue,
00328             $out
00329         );
00330     }
00331 
00332     /**
00333      * test add JS handler
00334      *
00335      */
00336     public function testAddExtOnReadyCode() {
00337 
00338         $expectedReturnValue1 = 'Ext.onReady(function() {';
00339         $expectedReturnValue2 = 'var x = "testvar";';
00340         $this->fixture->loadExtJS();
00341         $this->fixture->addExtOnReadyCode('var x = "testvar";');
00342         $out = $this->fixture->render();
00343 
00344         $this->assertContains(
00345             $expectedReturnValue1,
00346             $out
00347         );
00348 
00349         $this->assertContains(
00350             $expectedReturnValue2,
00351             $out
00352         );
00353 
00354     }
00355 
00356     /**
00357      * test add CSS file
00358      *
00359      */
00360     public function testAddCssFile() {
00361 
00362         $expectedReturnValue = '<link rel="stylesheet" type="text/css" href="fileadmin/test.css" media="all" />';
00363         $this->fixture->addCssFile('fileadmin/test.css');
00364         $out = $this->fixture->render();
00365 
00366         $this->assertContains(
00367             $expectedReturnValue,
00368             $out
00369         );
00370     }
00371 
00372     /**
00373      * test add CSS inline
00374      *
00375      */
00376     public function testAddCssInlineBlock() {
00377 
00378         $expectedReturnValue = 'body {margin:20px;}';
00379         $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}');
00380         $out = $this->fixture->render();
00381 
00382         $this->assertContains(
00383             $expectedReturnValue,
00384             $out
00385         );
00386     }
00387 
00388     /**
00389      * test add CSS inline and force on top
00390      *
00391      */
00392     public function testAddCssInlineBlockForceOnTop() {
00393 
00394         $expectedReturnValue = '/*general1*/' . LF . 'h1 {margin:20px;}' . LF . '/*general*/' . LF . 'body {margin:20px;}';
00395         $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}');
00396         $this->fixture->addCssInlineBlock('general1', 'h1 {margin:20px;}', NULL, TRUE);
00397         $out = $this->fixture->render();
00398 
00399         $this->assertContains(
00400             $expectedReturnValue,
00401             $out
00402         );
00403     }
00404 
00405     /**
00406      * test load prototype
00407      *
00408      */
00409     public function testLoadPrototype() {
00410 
00411         $expectedRegExp = '#<script src="contrib/prototype/prototype\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00412         $this->fixture->loadPrototype();
00413         $out = $this->fixture->render();
00414 
00415         $this->assertRegExp(
00416             $expectedRegExp,
00417             $out
00418         );
00419     }
00420 
00421     /**
00422      * test load Scriptaculous
00423      *
00424      */
00425     public function testLoadScriptaculous() {
00426         $this->fixture->loadScriptaculous('slider,controls');
00427         $out = $this->fixture->render();
00428 
00429         $this->assertContains(
00430             '<script src="contrib/scriptaculous/scriptaculous.js" type="text/javascript"></script>',
00431             $out
00432         );
00433         $this->assertContains(
00434             '<script src="contrib/scriptaculous/effects.js" type="text/javascript"></script>',
00435             $out
00436         );
00437         $this->assertContains(
00438             '<script src="contrib/scriptaculous/controls.js" type="text/javascript"></script>',
00439             $out
00440         );
00441         $this->assertContains(
00442             '<script src="contrib/scriptaculous/slider.js" type="text/javascript"></script>',
00443             $out
00444         );
00445     }
00446 
00447     /**
00448      * Tests whether scriptaculous is loaded correctly when compression is enabled.
00449      *
00450      * @test
00451      */
00452     public function isScriptaculousLoadedCompressedIfConfiguredAndClientIsCapable() {
00453         $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
00454         $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
00455 
00456         $this->fixture->loadScriptaculous('slider,controls');
00457         $this->fixture->enableCompressJavascript();
00458         $out = $this->fixture->render();
00459 
00460         $this->assertRegExp(
00461             '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
00462             $out
00463         );
00464         $this->assertRegExp(
00465             '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
00466             $out
00467         );
00468         $this->assertRegExp(
00469             '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
00470             $out
00471         );
00472         $this->assertRegExp(
00473             '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
00474             $out
00475         );
00476     }
00477 
00478     /**
00479      * Tests whether scriptaculous is correctly loaded, but without compression
00480      * if the browser did not send the appropriate headers.
00481      *
00482      * @test
00483      */
00484     public function isScriptaculousNotLoadedCompressedIfClientCannotHandleCompression() {
00485         $_SERVER['HTTP_ACCEPT_ENCODING'] = '';
00486         $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
00487 
00488         $this->fixture->loadScriptaculous('slider,controls');
00489         $this->fixture->enableCompressJavascript();
00490         $out = $this->fixture->render();
00491 
00492         $this->assertRegExp(
00493             '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#',
00494             $out
00495         );
00496         $this->assertRegExp(
00497             '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#',
00498             $out
00499         );
00500         $this->assertRegExp(
00501             '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#',
00502             $out
00503         );
00504         $this->assertRegExp(
00505             '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#',
00506             $out
00507         );
00508     }
00509 
00510     /**
00511      * Tests whether scriptaculous is correctly loaded, but without compression
00512      * if no compression is configured.
00513      *
00514      * @test
00515      */
00516     public function isScriptaculousNotLoadedCompressedIfCompressionIsNotConfigured() {
00517         $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
00518         $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '';
00519 
00520         $this->fixture->loadScriptaculous('slider,controls');
00521         $this->fixture->enableCompressJavascript();
00522         $out = $this->fixture->render();
00523 
00524         $this->assertRegExp(
00525             '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#',
00526             $out
00527         );
00528         $this->assertRegExp(
00529             '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#',
00530             $out
00531         );
00532         $this->assertRegExp(
00533             '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#',
00534             $out
00535         );
00536         $this->assertRegExp(
00537             '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#',
00538             $out
00539         );
00540     }
00541 
00542     /**
00543      * test load ExtJS
00544      *
00545      */
00546     public function testLoadExtJS() {
00547 
00548         $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';
00549         $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
00550         $out = $this->fixture->render();
00551 
00552         $this->assertRegExp(
00553             $expectedRegExp,
00554             $out
00555         );
00556     }
00557 
00558     /**
00559      * test load ExtCore
00560      *
00561      */
00562     public function testLoadExtCore() {
00563 
00564         $expectedRegExp = '#<script src="contrib/extjs/ext-core\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00565         $this->fixture->loadExtCore();
00566         $out = $this->fixture->render();
00567 
00568         $this->assertRegExp(
00569             $expectedRegExp,
00570             $out
00571         );
00572     }
00573 
00574     /**
00575      * test enable ExtJsDebug
00576      *
00577      */
00578     public function testEnableExtJsDebug() {
00579 
00580         $expectedRegExp = '#<script src="contrib/extjs/ext-all-debug\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00581         $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
00582         $this->fixture->enableExtJsDebug();
00583         $out = $this->fixture->render();
00584 
00585         $this->assertRegExp(
00586             $expectedRegExp,
00587             $out
00588         );
00589     }
00590 
00591     /**
00592      * test enable ExtCoreDebug
00593      *
00594      */
00595     public function testEnableExtCoreDebug() {
00596 
00597         $expectedRegExp = '#<script src="contrib/extjs/ext-core-debug\.(js|\d+\.js|js\?\d+)" type="text/javascript"></script>#';
00598         $this->fixture->loadExtCore();
00599         $this->fixture->enableExtCoreDebug();
00600         $out = $this->fixture->render();
00601 
00602         $this->assertRegExp(
00603             $expectedRegExp,
00604             $out
00605         );
00606     }
00607 
00608     /**
00609      * test inline language label
00610      *
00611      */
00612     public function testAddInlineLanguageLabel() {
00613 
00614         $expectedReturnValue = 'TYPO3.lang = {"myKey":"myValue"}';
00615         $this->fixture->loadExtJS();
00616         $this->fixture->addInlineLanguageLabel('myKey', 'myValue');
00617         $out = $this->fixture->enableMoveJsFromHeaderToFooter();
00618         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00619 
00620         $this->assertContains(
00621             $expectedReturnValue,
00622             $out
00623         );
00624     }
00625 
00626     /**
00627      * test inline language label as array
00628      *
00629      */
00630     public function testAddInlineLanguageLabelArray() {
00631 
00632         $expectedReturnValue = 'TYPO3.lang = {"myKey1":"myValue1","myKey2":"myValue2"}';
00633         $this->fixture->loadExtJS();
00634         $this->fixture->addInlineLanguageLabelArray(array('myKey1' => 'myValue1', 'myKey2' => 'myValue2',));
00635         $out = $this->fixture->enableMoveJsFromHeaderToFooter();
00636         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00637 
00638         $this->assertContains(
00639             $expectedReturnValue,
00640             $out
00641         );
00642     }
00643 
00644     /**
00645      * test inline language label as array get merged
00646      *
00647      */
00648     public function testAddInlineLanguageLabelArrayMerged() {
00649 
00650         $expectedReturnValue = 'TYPO3.lang = {"myKey1":"myValue1","myKey2":"myValue2"}';
00651         $this->fixture->loadExtJS();
00652         $this->fixture->addInlineLanguageLabelArray(array('myKey1' => 'myValue1',));
00653         $this->fixture->addInlineLanguageLabelArray(array('myKey2' => 'myValue2',));
00654         $out = $this->fixture->enableMoveJsFromHeaderToFooter();
00655         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00656 
00657         $this->assertContains(
00658             $expectedReturnValue,
00659             $out
00660         );
00661     }
00662 
00663     /**
00664      * test inline setting
00665      *
00666      */
00667     public function testAddInlineSetting() {
00668 
00669         $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey":"myValue"}};';
00670         $this->fixture->loadExtJS();
00671         $this->fixture->addInlineSetting('myApp', 'myKey', 'myValue');
00672         $out = $this->fixture->enableMoveJsFromHeaderToFooter();
00673         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00674 
00675         $this->assertContains(
00676             $expectedReturnValue,
00677             $out
00678         );
00679     }
00680 
00681     /**
00682      * test inline settings with array
00683      *
00684      */
00685     public function testAddInlineSettingArray() {
00686 
00687         $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey1":"myValue1","myKey2":"myValue2"}};';
00688         $this->fixture->loadExtJS();
00689         $this->fixture->addInlineSettingArray('myApp', array('myKey1' => 'myValue1', 'myKey2' => 'myValue2',));
00690         $out = $this->fixture->enableMoveJsFromHeaderToFooter();
00691         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00692 
00693         $this->assertContains(
00694             $expectedReturnValue,
00695             $out
00696         );
00697     }
00698 
00699     /**
00700      * test inline settings with array get merged
00701      *
00702      */
00703     public function testAddInlineSettingArrayMerged() {
00704 
00705         $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey1":"myValue1","myKey2":"myValue2"}};';
00706         $this->fixture->loadExtJS();
00707         $this->fixture->addInlineSettingArray('myApp', array('myKey1' => 'myValue1',));
00708         $this->fixture->addInlineSettingArray('myApp', array('myKey2' => 'myValue2',));
00709         $out = $this->fixture->enableMoveJsFromHeaderToFooter();
00710         $out = $this->fixture->render(t3lib_PageRenderer::PART_FOOTER);
00711 
00712         $this->assertContains(
00713             $expectedReturnValue,
00714             $out
00715         );
00716     }
00717 
00718     /**
00719      * test add body content
00720      *
00721      */
00722     public function testAddBodyContent() {
00723         $expectedReturnValue = 'ABCDE';
00724         $this->fixture->addBodyContent('A');
00725         $this->fixture->addBodyContent('B');
00726         $this->fixture->addBodyContent('C');
00727         $this->fixture->addBodyContent('D');
00728         $this->fixture->addBodyContent('E');
00729 
00730         $out = $this->fixture->getBodyContent();
00731         $this->assertEquals(
00732             $expectedReturnValue,
00733             $out
00734         );
00735     }
00736 
00737 
00738     /**
00739      * test set body content
00740      *
00741      */
00742     public function testSetBodyContent() {
00743         $expectedReturnValue = 'ABCDE';
00744         $this->fixture->setBodyContent('ABCDE');
00745 
00746         $out = $this->fixture->getBodyContent();
00747         $this->assertEquals(
00748             $expectedReturnValue,
00749             $out
00750         );
00751 
00752         $out = $this->fixture->render();
00753 
00754         $this->assertContains(
00755             $expectedReturnValue,
00756             $out
00757         );
00758     }
00759 
00760     /**
00761      * Tests whether labels are delivered in a non-UTF-8 context.
00762      * (background: json_encode() requires UTF-8 to work properly)
00763      *
00764      * @test
00765      */
00766     public function isInlineLanguageLabelDeliveredWithNonUTF8() {
00767         $testPrefix = uniqid('test');
00768         $this->fixture->loadExtCore();
00769         $this->fixture->setCharSet('iso-8859-1');
00770         $this->fixture->addInlineLanguageLabel($testPrefix, $testPrefix . "_\xd8");
00771 
00772         $out = $this->fixture->render();
00773 
00774         $this->assertContains($testPrefix . '_\\u00d8', $out);
00775     }
00776 
00777     /**
00778      * Tests the addInlineLanguageLabelFile() method.
00779      *
00780      * @test
00781      * @expectedException RuntimeException
00782      */
00783     public function areInlineLanguageLabelsNotProcessable() {
00784         $this->fixture->setLanguage(NULL);
00785         $this->fixture->addInlineLanguageLabelFile(
00786             'EXT:lang/locallang_core.xml'
00787         );
00788         $out = $this->fixture->render();
00789     }
00790 
00791     /**
00792      * Tests the addInlineLanguageLabelFile() method.
00793      *
00794      * @test
00795      */
00796     public function areInlineLanguageLabelsPassed() {
00797         $this->fixture->setLanguage($GLOBALS['LANG']->lang);
00798         $this->fixture->addInlineLanguageLabelFile(
00799             'EXT:lang/locallang_core.xml'
00800         );
00801 
00802         $out = $this->fixture->render();
00803 
00804         $this->assertContains('labels.beUser', $out);
00805         $this->assertContains('labels.feUser', $out);
00806     }
00807 
00808     /**
00809      * Tests the addInlineLanguageLabelFile() method.
00810      *
00811      * @test
00812      */
00813     public function areInlineLanguageLabelsEmptyOnNonExistingFile() {
00814         $this->fixture->addInlineLanguageLabelFile(
00815             ''
00816         );
00817 
00818         $inlineLanguageLabelFiles = $this->fixture->getInlineLanguageLabelFiles();
00819         $this->assertEquals(array(), $inlineLanguageLabelFiles);
00820     }
00821 
00822     /**
00823      * Tests the addInlineLanguageLabelFile() method.
00824      *
00825      * @test
00826      */
00827     public function areInlineLanguageLabelsSelected() {
00828         $this->fixture->setLanguage($GLOBALS['LANG']->lang);
00829         $this->fixture->addInlineLanguageLabelFile(
00830             'EXT:lang/locallang_core.xml',
00831             'labels.'
00832         );
00833 
00834         $out = $this->fixture->render();
00835         $this->assertContains('labels.beUser', $out);
00836         $this->assertContains('labels.feUser', $out);
00837     }
00838 
00839     /**
00840      * Tests the addInlineLanguageLabelFile() method.
00841      *
00842      * @test
00843      */
00844     public function areInlineLanguageLabelsSelectedAndStripped() {
00845         $this->fixture->setLanguage($GLOBALS['LANG']->lang);
00846         $this->fixture->addInlineLanguageLabelFile(
00847             'EXT:lang/locallang_core.xml',
00848             'labels.',
00849             'lock'
00850         );
00851 
00852         $out = $this->fixture->render();
00853 
00854         $this->assertContains('edRecord', $out);
00855         $this->assertContains('edRecord_content', $out);
00856         $this->assertContains('edRecordUser', $out);
00857     }
00858 }
00859 ?>