Example #1
0
 /**
  * @test
  */
 public function pageRendererRendersFooterValues()
 {
     $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
     $subject->setCharSet('utf-8');
     $subject->setLanguage('default');
     $subject->enableMoveJsFromHeaderToFooter();
     $footerData = $expectedFooterData = '<tag method="private" name="test" />';
     $subject->addFooterData($footerData);
     $expectedJsFooterLibraryRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#';
     $subject->addJsFooterLibrary('test', 'fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
     $expectedJsFooterRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#';
     $subject->addJsFooterFile('fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
     $jsFooterInlineCode = $expectedJsFooterInlineCodeString = 'var x = "' . $this->getUniqueId('jsFooterInline-') . '"';
     $subject->addJsFooterInlineCode($this->getUniqueId(), $jsFooterInlineCode);
     // Bunch of label tests
     $subject->loadExtJS();
     $subject->addInlineLanguageLabel('myKey', 'myValue');
     $subject->addInlineLanguageLabelArray(array('myKeyArray1' => 'myValueArray1', 'myKeyArray2' => 'myValueArray2'));
     $subject->addInlineLanguageLabelArray(array('myKeyArray3' => 'myValueArray3'));
     $expectedInlineLabelReturnValue = 'TYPO3.lang = {"myKey":"myValue","myKeyArray1":"myValueArray1","myKeyArray2":"myValueArray2","myKeyArray3":"myValueArray3"';
     $subject->addInlineLanguageLabelFile('EXT:lang/locallang_core.xlf');
     $expectedLanguageLabel1 = 'labels.beUser';
     $expectedLanguageLabel2 = 'labels.feUser';
     // Bunch of inline settings test
     $subject->addInlineSetting('myApp', 'myKey', 'myValue');
     $subject->addInlineSettingArray('myApp', array('myKey1' => 'myValue1', 'myKey2' => 'myValue2'));
     $subject->addInlineSettingArray('myApp', array('myKey3' => 'myValue3'));
     $expectedInlineSettingsReturnValue = 'TYPO3.settings = {"myApp":{"myKey":"myValue","myKey1":"myValue1","myKey2":"myValue2","myKey3":"myValue3"}';
     $renderedString = $subject->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
     $this->assertContains($expectedFooterData, $renderedString);
     $this->assertRegExp($expectedJsFooterLibraryRegExp, $renderedString);
     $this->assertRegExp($expectedJsFooterRegExp, $renderedString);
     $this->assertContains($expectedJsFooterInlineCodeString, $renderedString);
     $this->assertContains($expectedInlineLabelReturnValue, $renderedString);
     $this->assertContains($expectedLanguageLabel1, $renderedString);
     $this->assertContains($expectedLanguageLabel2, $renderedString);
     $this->assertContains($expectedInlineSettingsReturnValue, $renderedString);
 }