/** * @test */ public function pageRendererRendersInsertsMainContentStringsInOutput() { $subject = new \TYPO3\CMS\Core\Page\PageRenderer(); $subject->setCharSet('utf-8'); $subject->setLanguage('default'); $prologueString = $expectedPrologueString = '<?xml version="1.0" encoding="utf-8" ?>'; $subject->setXmlPrologAndDocType($prologueString); $title = $this->getUniqueId('aTitle-'); $subject->setTitle($title); $expectedTitleString = '<title>' . $title . '</title>'; $charset = 'utf-8'; $subject->setCharSet($charset); $expectedCharsetString = '<meta http-equiv="Content-Type" content="text/html; charset=' . $charset . '" />'; $favouriteIcon = 'http://google.com/favicon.ico'; $subject->setFavIcon($favouriteIcon); $expectedFavouriteIconPartOne = '<link rel="shortcut icon" href="' . $favouriteIcon . '" />'; $expectedFavouriteIconPartTwo = '<link rel="icon" href="' . $favouriteIcon . '" />'; $baseUrl = 'http://google.com/'; $subject->setBaseUrl($baseUrl); $expectedBaseUrlString = '<base href="' . $baseUrl . '" />'; $metaTag = $expectedMetaTagString = '<meta name="author" content="Anna Lyse">'; $subject->addMetaTag($metaTag); $inlineComment = $this->getUniqueId('comment'); $subject->addInlineComment($inlineComment); $expectedInlineCommentString = '<!-- ' . LF . $inlineComment . '-->'; $headerData = $expectedHeaderData = '<tag method="private" name="test" />'; $subject->addHeaderData($headerData); $subject->addJsLibrary('test', 'fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X'); $expectedJsLibraryRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#'; $subject->addJsFile('fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X'); $expectedJsFileRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#'; $jsInlineCode = $expectedJsInlineCodeString = 'var x = "' . $this->getUniqueId('jsInline-') . '"'; $subject->addJsInlineCode($this->getUniqueId(), $jsInlineCode); $extOnReadyCode = $expectedExtOnReadyCodePartOne = $this->getUniqueId('extOnReady-'); $expectedExtOnReadyCodePartTwo = 'Ext.onReady(function() {'; $subject->loadExtJS(); $subject->addExtOnReadyCode($extOnReadyCode); $cssFile = $this->getUniqueId('cssFile-'); $expectedCssFileString = 'wrapBefore<link rel="stylesheet" type="text/css" href="' . $cssFile . '" media="print" />wrapAfter'; $subject->addCssFile($cssFile, 'stylesheet', 'print', '', TRUE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X'); $expectedCssInlineBlockOnTopString = '/*general3*/' . LF . 'h1 {margin:20px;}' . LF . '/*general2*/' . LF . 'body {margin:20px;}'; $subject->addCssInlineBlock('general2', 'body {margin:20px;}'); $subject->addCssInlineBlock('general3', 'h1 {margin:20px;}', NULL, TRUE); $expectedLoadPrototypeRegExp = '#<script src="contrib/prototype/prototype\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#'; $subject->loadPrototype(); $subject->loadScriptaculous('slider,controls'); $expectedScriptaculousMain = '<script src="contrib/scriptaculous/scriptaculous.js" type="text/javascript"></script>'; $expectedScriptaculousEffects = '<script src="contrib/scriptaculous/effects.js" type="text/javascript"></script>'; $expectedScriptaculousControls = '<script src="contrib/scriptaculous/controls.js" type="text/javascript"></script>'; $expectedScriptaculousSlider = '<script src="contrib/scriptaculous/slider.js" type="text/javascript"></script>'; $subject->loadJquery(); $expectedJqueryRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#'; $expectedJqueryStatement = 'var TYPO3 = TYPO3 || {}; TYPO3.jQuery = jQuery.noConflict(true);'; $subject->loadExtJS(TRUE, TRUE, 'jquery'); $expectedExtJsRegExp = '#<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'; $expectedBodyContent = $this->getUniqueId('ABCDE-'); $subject->setBodyContent($expectedBodyContent); $renderedString = $subject->render(); $this->assertContains($expectedPrologueString, $renderedString); $this->assertContains($expectedTitleString, $renderedString); $this->assertContains($expectedCharsetString, $renderedString); $this->assertContains($expectedFavouriteIconPartOne, $renderedString); $this->assertContains($expectedFavouriteIconPartTwo, $renderedString); $this->assertContains($expectedBaseUrlString, $renderedString); $this->assertContains($expectedMetaTagString, $renderedString); $this->assertContains($expectedInlineCommentString, $renderedString); $this->assertContains($expectedHeaderData, $renderedString); $this->assertRegExp($expectedJsLibraryRegExp, $renderedString); $this->assertRegExp($expectedJsFileRegExp, $renderedString); $this->assertContains($expectedJsInlineCodeString, $renderedString); $this->assertContains($expectedExtOnReadyCodePartOne, $renderedString); $this->assertContains($expectedExtOnReadyCodePartTwo, $renderedString); $this->assertContains($expectedCssFileString, $renderedString); $this->assertContains($expectedCssInlineBlockOnTopString, $renderedString); $this->assertRegExp($expectedLoadPrototypeRegExp, $renderedString); $this->assertContains($expectedScriptaculousMain, $renderedString); $this->assertContains($expectedScriptaculousEffects, $renderedString); $this->assertContains($expectedScriptaculousControls, $renderedString); $this->assertContains($expectedScriptaculousSlider, $renderedString); $this->assertRegExp($expectedJqueryRegExp, $renderedString); $this->assertContains($expectedJqueryStatement, $renderedString); $this->assertRegExp($expectedExtJsRegExp, $renderedString); $this->assertContains($expectedBodyContent, $renderedString); }