[TASK] Refactor PageRenderer tests 04/25304/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 10 Nov 2013 12:57:21 +0000 (13:57 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 12 Nov 2013 19:07:59 +0000 (20:07 +0100)
The existing tests of ext:core/Page/PageRenderer are in fact
functional tests since most of them trigger lots of dependencies
and call the main API method "render()" to check for something.

The patch moves most detail tests to two general functional tests
doing the main work and adds some more functional tests for more
specific cases.
The unit tests are stripped down to those parts that test only single
methods or smaller systems with proper mocking.

In effect, the full unit test suite does no longer depend on
initialization of $GLOBALS['LANG'], it is now removed from unit
test bootstrap.

Change-Id: I9f3f54ba52673e16bfcd303b46755e079d240de6
Resolves: #53558
Related: #51436
Related: #53476
Releases: 6.2
Reviewed-on: https://review.typo3.org/25304
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Build/UnitTestsBootstrap.php
typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Page/PageRendererTest.php

index a76b44e..6d1d574 100644 (file)
@@ -105,6 +105,4 @@ require PATH_site . '/typo3/sysext/core/Classes/Core/Bootstrap.php';
        ->loadExtensionTables(TRUE)
        ->initializeBackendUser()
        // TODO: Fix FAL tests which fatal without initialized storages
-       ->initializeBackendUserMounts()
-       // TODO: Needed at least for FormProtection tests
-       ->initializeLanguageObject();
+       ->initializeBackendUserMounts();
diff --git a/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php b/typo3/sysext/core/Tests/Functional/Page/PageRendererTest.php
new file mode 100644 (file)
index 0000000..7563ac7
--- /dev/null
@@ -0,0 +1,399 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Functional\Page;
+
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Test case
+ */
+class PageRendererTest extends \TYPO3\CMS\Core\Tests\FunctionalTestCase {
+
+       /**
+        * @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 = uniqid('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 = uniqid('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 = "' . uniqid('jsInline-') . '"';
+               $subject->addJsInlineCode(uniqid(), $jsInlineCode);
+
+               $extOnReadyCode = $expectedExtOnReadyCodePartOne = uniqid('extOnReady-');
+               $expectedExtOnReadyCodePartTwo = 'Ext.onReady(function() {';
+               $subject->loadExtJS();
+               $subject->addExtOnReadyCode($extOnReadyCode);
+
+               $cssFile = uniqid('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 = uniqid('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);
+       }
+
+       /**
+        * @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 = "' . uniqid('jsFooterInline-') . '"';
+               $subject->addJsFooterInlineCode(uniqid(), $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);
+       }
+
+       /**
+        * @test
+        */
+       public function isScriptaculousLoadedCompressedIfConfiguredAndClientIsCapable() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
+               $subject->loadScriptaculous('slider,controls');
+               $subject->enableCompressJavascript();
+               $out = $subject->render();
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
+       }
+
+       /**
+        * @test
+        */
+       public function isScriptaculousNotLoadedCompressedIfClientCannotHandleCompression() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $_SERVER['HTTP_ACCEPT_ENCODING'] = '';
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
+               $subject->loadScriptaculous('slider,controls');
+               $subject->enableCompressJavascript();
+               $out = $subject->render();
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+       }
+
+       /**
+        * @test
+        */
+       public function isScriptaculousNotLoadedCompressedIfCompressionIsNotConfigured() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '';
+               $subject->loadScriptaculous('slider,controls');
+               $subject->enableCompressJavascript();
+               $out = $subject->render();
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadJqueryRespectsGivenNamespace() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $expectedStatement = 'var TYPO3 = TYPO3 || {}; TYPO3.MyNameSpace = jQuery.noConflict(true);';
+               $subject->loadJquery(NULL, NULL, 'MyNameSpace');
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+               $this->assertContains($expectedStatement, $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadJqueryWithDefaultNoConflictModeDoesNotSetNamespace() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $expectedStatement = 'jQuery.noConflict();';
+               $subject->loadJquery(NULL, NULL, \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT);
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+               $this->assertContains($expectedStatement, $out);
+               $this->assertNotContains('var TYPO3 = TYPO3 || {}; TYPO3.', $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadJqueryWithNamespaceNoneDoesNotIncludeNoConflictHandling() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $subject->loadJquery(NULL, NULL, \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_NONE);
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+               $this->assertNotContains('jQuery.noConflict', $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadJqueryLoadsTheLatestJqueryVersionInNoConflictModeUncompressedInDebugMode() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $expectedStatement = 'var TYPO3 = TYPO3 || {}; TYPO3.jQuery = jQuery.noConflict(true);';
+               $subject->loadJquery();
+               $subject->enableDebugMode();
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+               $this->assertContains($expectedStatement, $out);
+       }
+
+       /**
+        * @return array
+        */
+       public function loadJqueryFromSourceDataProvider() {
+               return array(
+                       'google with version number' => array(
+                               '1.6.3',
+                               'google',
+                               '#<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.js" type="text/javascript"></script>#'
+                       ),
+                       'msn with version number' => array(
+                               '1.6.3',
+                               'msn',
+                               '#<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.3.js" type="text/javascript"></script>#'
+                       ),
+                       'jquery with version number' => array(
+                               '1.6.3',
+                               'jquery',
+                               '#<script src="http://code.jquery.com/jquery-1.6.3.js" type="text/javascript"></script>#'
+                       ),
+                       'jquery with custom URL' => array(
+                               '1.6.3',
+                               'http://my.cool.cdn/foo/jquery.js',
+                               '#<script src="http://my.cool.cdn/foo/jquery.js" type="text/javascript"></script>#'
+                       ),
+               );
+       }
+
+       /**
+        * @dataProvider loadJqueryFromSourceDataProvider
+        * @test
+        */
+       public function isJqueryLoadedFromSourceUncompressedIfDebugModeIsEnabled($version, $source, $regex) {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $subject->loadJquery($version, $source);
+               $subject->enableDebugMode();
+               $out = $subject->render();
+               $this->assertRegExp($regex, $out);
+       }
+
+       /**
+        * @test
+        */
+       public function isJqueryLoadedMinifiedFromGoogleByDefault($version, $cdn, $regex) {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegex = '#<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script>#';
+               $subject->loadJquery('1.6.3', 'google');
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegex, $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadExtJsInDebugLoadsDebugExtJs() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/extjs/ext-all-debug\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $subject->loadExtJS(TRUE, TRUE, 'jquery');
+               $subject->enableExtJsDebug();
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadExtCoreLoadsExtCore() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/extjs/ext-core\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $subject->loadExtCore();
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+       }
+
+       /**
+        * @test
+        */
+       public function loadExtCoreInDebugLoadsDebugExtCore() {
+               $subject = new \TYPO3\CMS\Core\Page\PageRenderer();
+
+               $expectedRegExp = '#<script src="contrib/extjs/ext-core-debug\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
+               $subject->loadExtCore();
+               $subject->enableExtCoreDebug();
+               $out = $subject->render();
+               $this->assertRegExp($expectedRegExp, $out);
+       }
+}
index d295283..94e8c47 100644 (file)
@@ -23,389 +23,23 @@ namespace TYPO3\CMS\Core\Tests\Unit\Page;
  *
  * This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
 /**
- * Testcase for \TYPO3\CMS\Core\Page\PageRenderer
+ * Unit test case
  *
- * @author Steffen Kamper (info@sk-typo3.de)
+ * @see According functional test case
  */
 class PageRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Page\PageRenderer
-        */
-       private $fixture;
-
-       public function setUp() {
-               $this->fixture = new \TYPO3\CMS\Core\Page\PageRenderer();
-               $this->fixture->setCharSet($GLOBALS['LANG']->charSet);
-       }
-
-       public function tearDown() {
-               unset($this->fixture);
-       }
-
-       //////////////////////////////////////
-       // Tests for the basic functionality
-       //////////////////////////////////////
-       /**
-        * @test
-        */
-       public function fixtureCanBeCreated() {
-               $this->assertTrue($this->fixture instanceof \TYPO3\CMS\Core\Page\PageRenderer);
-       }
-
-       //////////////////////
-       // test functions
-       //////////////////////
-       /**
-        * test set xml prolog and doctype
-        */
-       public function testSetXmlPrologAndDocType() {
-               $expectedReturnValue = '<?xml version="1.0" encoding="utf-8" ?>';
-               $this->fixture->setXmlPrologAndDocType('<?xml version="1.0" encoding="utf-8" ?>');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test set title
-        */
-       public function testSetTitle() {
-               $expectedReturnValue = '<title>This is the title</title>';
-               $this->fixture->setTitle('This is the title');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test set charset
-        */
-       public function testSetCharset() {
-               $expectedReturnValue = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
-               $this->fixture->setCharset('utf-8');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test set favicon
-        */
-       public function testSetFavIcon() {
-               $expectedReturnValue1 = '<link rel="shortcut icon" href="http://google.com/favicon.ico" />';
-               $expectedReturnValue2 = '<link rel="icon" href="http://google.com/favicon.ico" />';
-               $this->fixture->setFavIcon('http://google.com/favicon.ico');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue1, $out);
-               $this->assertContains($expectedReturnValue2, $out);
-       }
-
-       /**
-        * test set baseUrl
-        */
-       public function testSetBaseUrl() {
-               $expectedReturnValue = '<base href="http://ggogle.com/" />';
-               $this->fixture->setBaseUrl('http://ggogle.com/');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add meta tag
-        */
-       public function testAddMetaTag() {
-               $expectedReturnValue = '<meta name="author" content="Anna Lyse">';
-               $this->fixture->addMetaTag('<meta name="author" content="Anna Lyse">');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add inline comment
-        */
-       public function testAddInlineComment() {
-               $expectedReturnValue = 'this is an inline comment written by unit test';
-               $this->fixture->addInlineComment('this is an inline comment written by unit test');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add header data
-        */
-       public function testAddHeaderData() {
-               $expectedReturnValue = '<tag method="private" name="test" />';
-               $this->fixture->addHeaderData('<tag method="private" name="test" />');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add footer data
-        */
-       public function testAddFooterData() {
-               $expectedReturnValue = '<tag method="private" name="test" />';
-               $this->fixture->addFooterData('<tag method="private" name="test" />');
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add JS library file
-        */
-       public function testAddJsLibrary() {
-               $expectedRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#';
-               $this->fixture->addJsLibrary('test', 'fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test add JS footer library file
-        */
-       public function testAddJsFooterLibrary() {
-               $expectedRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#';
-               $this->fixture->addJsFooterLibrary('test', 'fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test add JS file
-        */
-       public function testAddJsFile() {
-               $expectedRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#';
-               $this->fixture->addJsFile('fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test add JS file for footer
-        */
-       public function testAddJsFooterFile() {
-               $expectedRegExp = '#wrapBefore<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>wrapAfter#';
-               $this->fixture->addJsFooterFile('fileadmin/test.js', 'text/javascript', FALSE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test add JS inline
-        */
-       public function testAddJsInlineCode() {
-               $expectedReturnValue = 'var x = "testvar"';
-               $this->fixture->addJsInlineCode('test', 'var x = "testvar"');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add JS inline for footer
-        */
-       public function testAddJsFooterInlineCode() {
-               $expectedReturnValue = 'var x = "testvar"';
-               $this->fixture->addJsFooterInlineCode('test', 'var x = "testvar"');
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add JS handler
-        */
-       public function testAddExtOnReadyCode() {
-               $expectedReturnValue1 = 'Ext.onReady(function() {';
-               $expectedReturnValue2 = 'var x = "testvar";';
-               $this->fixture->loadExtJS();
-               $this->fixture->addExtOnReadyCode('var x = "testvar";');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue1, $out);
-               $this->assertContains($expectedReturnValue2, $out);
-       }
-
-       /**
-        * test add CSS file
-        */
-       public function testAddCssFile() {
-               $expectedReturnValue = 'wrapBefore<link rel="stylesheet" type="text/css" href="fileadmin/test.css" media="print" />wrapAfter';
-               $this->fixture->addCssFile('fileadmin/test.css', 'stylesheet', 'print', '', TRUE, FALSE, 'wrapBeforeXwrapAfter', FALSE, 'X');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add CSS inline
-        */
-       public function testAddCssInlineBlock() {
-               $expectedReturnValue = 'body {margin:20px;}';
-               $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}');
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test add CSS inline and force on top
-        */
-       public function testAddCssInlineBlockForceOnTop() {
-               $expectedReturnValue = '/*general1*/' . LF . 'h1 {margin:20px;}' . LF . '/*general*/' . LF . 'body {margin:20px;}';
-               $this->fixture->addCssInlineBlock('general', 'body {margin:20px;}');
-               $this->fixture->addCssInlineBlock('general1', 'h1 {margin:20px;}', NULL, TRUE);
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test load prototype
-        */
-       public function testLoadPrototype() {
-               $expectedRegExp = '#<script src="contrib/prototype/prototype\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $this->fixture->loadPrototype();
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test load Scriptaculous
-        */
-       public function testLoadScriptaculous() {
-               $this->fixture->loadScriptaculous('slider,controls');
-               $out = $this->fixture->render();
-               $this->assertContains('<script src="contrib/scriptaculous/scriptaculous.js" type="text/javascript"></script>', $out);
-               $this->assertContains('<script src="contrib/scriptaculous/effects.js" type="text/javascript"></script>', $out);
-               $this->assertContains('<script src="contrib/scriptaculous/controls.js" type="text/javascript"></script>', $out);
-               $this->assertContains('<script src="contrib/scriptaculous/slider.js" type="text/javascript"></script>', $out);
-       }
-
-       /**
-        * Tests whether scriptaculous is loaded correctly when compression is enabled.
-        *
-        * @test
-        */
-       public function isScriptaculousLoadedCompressedIfConfiguredAndClientIsCapable() {
-               $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
-               $this->fixture->loadScriptaculous('slider,controls');
-               $this->fixture->enableCompressJavascript();
-               $out = $this->fixture->render();
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js.gzip" type="text/javascript"></script>#', $out);
-       }
-
-       /**
-        * Tests whether scriptaculous is correctly loaded, but without compression
-        * if the browser did not send the appropriate headers.
-        *
-        * @test
-        */
-       public function isScriptaculousNotLoadedCompressedIfClientCannotHandleCompression() {
-               $_SERVER['HTTP_ACCEPT_ENCODING'] = '';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5';
-               $this->fixture->loadScriptaculous('slider,controls');
-               $this->fixture->enableCompressJavascript();
-               $out = $this->fixture->render();
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-       }
-
-       /**
-        * Tests whether scriptaculous is correctly loaded, but without compression
-        * if no compression is configured.
-        *
-        * @test
-        */
-       public function isScriptaculousNotLoadedCompressedIfCompressionIsNotConfigured() {
-               $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '';
-               $this->fixture->loadScriptaculous('slider,controls');
-               $this->fixture->enableCompressJavascript();
-               $out = $this->fixture->render();
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-               $this->assertRegExp('#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#', $out);
-       }
-
-       /**
-        * test load jQuery
-        *
-        * @test
-        */
-       public function loadJqueryLoadsTheLatestJqueryMinifiedVersionInNoConflictMode() {
-               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $expectedStatement = 'var TYPO3 = TYPO3 || {}; TYPO3.jQuery = jQuery.noConflict(true);';
-               $this->fixture->loadJquery();
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-               $this->assertContains($expectedStatement, $out);
-       }
-
-       /**
-        * test load jQuery
-        *
-        * @test
-        */
-       public function loadJqueryRespectsGivenNamespace() {
-               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $expectedStatement = 'var TYPO3 = TYPO3 || {}; TYPO3.MyNameSpace = jQuery.noConflict(true);';
-               $this->fixture->loadJquery(NULL, NULL, 'MyNameSpace');
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-               $this->assertContains($expectedStatement, $out);
-       }
-
-       /**
-        * test load jQuery
-        *
-        * @test
-        */
-       public function loadJqueryWithDefaultNoConflictModeDoesNotSetNamespace() {
-               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $expectedStatement = 'jQuery.noConflict();';
-               $this->fixture->loadJquery(NULL, NULL, \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_DEFAULT_NOCONFLICT);
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-               $this->assertContains($expectedStatement, $out);
-               $this->assertNotContains('var TYPO3 = TYPO3 || {}; TYPO3.', $out);
-       }
-
-       /**
-        * test load jQuery
-        *
-        * @test
-        */
-       public function loadJqueryWithNamespaceNoneDoesNotIncludeNoConflictHandling() {
-               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.min\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $this->fixture->loadJquery(NULL, NULL, \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_NAMESPACE_NONE);
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-               $this->assertNotContains('jQuery.noConflict', $out);
-       }
-
-       /**
-        * test load jQuery
-        *
-        * @test
-        */
-       public function loadJqueryLoadsTheLatestJqueryVersionInNoConflictModeUncompressedInDebugMode() {
-               $expectedRegExp = '#<script src="contrib/jquery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $expectedStatement = 'var TYPO3 = TYPO3 || {}; TYPO3.jQuery = jQuery.noConflict(true);';
-               $this->fixture->loadJquery();
-               $this->fixture->enableDebugMode();
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-               $this->assertContains($expectedStatement, $out);
-       }
-
-       /**
         * @expectedException \UnexpectedValueException
         * @test
         */
        public function includingNotAvailableLocalJqueryVersionThrowsException() {
-               $this->fixture->loadJquery('1.3.34');
-               $this->fixture->render();
+               /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
+               $subject->_set('availableLocalJqueryVersions', array('1.1.1'));
+               $subject->loadJquery('2.2.2');
        }
 
        /**
@@ -413,269 +47,100 @@ class PageRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function includingJqueryWithNonAlphnumericNamespaceThrowsException() {
-               $this->fixture->loadJquery(NULL, NULL, '12sd.12fsd');
-               $this->fixture->render();
-       }
-
-       /**
-        * @return array
-        */
-       public function loadJqueryFromSourceDataProvider() {
-               $specificVersion = '1.6.3';
-               return array(
-                       'google with no version number' => array(NULL, 'google', '#<script src="//ajax.googleapis.com/ajax/libs/jquery/' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '/jquery.js" type="text/javascript"></script>#'),
-                       'google with version number' => array($specificVersion, 'google', '#<script src="//ajax.googleapis.com/ajax/libs/jquery/' . $specificVersion . '/jquery.js" type="text/javascript"></script>#'),
-                       'msn with no version number' => array(NULL, 'msn', '#<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '.js" type="text/javascript"></script>#'),
-                       'msn with version number' => array($specificVersion, 'msn', '#<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . $specificVersion . '.js" type="text/javascript"></script>#'),
-                       'jquery with no version number' => array(NULL, 'jquery', '#<script src="http://code.jquery.com/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '.js" type="text/javascript"></script>#'),
-                       'jquery with version number' => array($specificVersion, 'jquery', '#<script src="http://code.jquery.com/jquery-' . $specificVersion . '.js" type="text/javascript"></script>#'),
-                       'jquery with custom URL' => array($specificVersion, 'http://my.cool.cdn/foo/jquery.js', '#<script src="http://my.cool.cdn/foo/jquery.js" type="text/javascript"></script>#')
-               );
+               /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
+               $subject->loadJquery(NULL, NULL, '12sd.12fsd');
+               $subject->render();
        }
 
        /**
-        * Tests whether jQuery is correctly loaded, from the respective CDNs
-        *
-        * @dataProvider loadJqueryFromSourceDataProvider
         * @test
         */
-       public function isJqueryLoadedFromSourceUncompressedIfDebugModeIsEnabled($version, $source, $regex) {
-               $this->fixture->loadJquery($version, $source);
-               $this->fixture->enableDebugMode();
-               $out = $this->fixture->render();
-               $this->assertRegExp($regex, $out);
-       }
-
-       /**
-        * @return array
-        */
-       public function loadJqueryMinifiedFromSourceDataProvider() {
-               $specificVersion = '1.6.3';
-               return array(
-                       'google with no version number' => array(NULL, 'google', '#<script src="//ajax.googleapis.com/ajax/libs/jquery/' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '/jquery.min.js" type="text/javascript"></script>#'),
-                       'google with version number' => array($specificVersion, 'google', '#<script src="//ajax.googleapis.com/ajax/libs/jquery/' . $specificVersion . '/jquery.min.js" type="text/javascript"></script>#'),
-                       'msn with no version number' => array(NULL, 'msn', '#<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '.min.js" type="text/javascript"></script>#'),
-                       'msn with version number' => array($specificVersion, 'msn', '#<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . $specificVersion . '.min.js" type="text/javascript"></script>#'),
-                       'jquery with no version number' => array(NULL, 'jquery', '#<script src="http://code.jquery.com/jquery-' . \TYPO3\CMS\Core\Page\PageRenderer::JQUERY_VERSION_LATEST . '.min.js" type="text/javascript"></script>#'),
-                       'jquery with version number' => array($specificVersion, 'jquery', '#<script src="http://code.jquery.com/jquery-' . $specificVersion . '.min.js" type="text/javascript"></script>#')
-               );
+       public function addBodyContentAddsContent() {
+               /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
+               $expectedReturnValue = 'ABCDE';
+               $subject->addBodyContent('A');
+               $subject->addBodyContent('B');
+               $subject->addBodyContent('C');
+               $subject->addBodyContent('D');
+               $subject->addBodyContent('E');
+               $out = $subject->getBodyContent();
+               $this->assertEquals($expectedReturnValue, $out);
        }
 
        /**
-        * Tests whether jQuery is correctly loaded, from the respective CDNs
-        *
-        * @dataProvider loadJqueryMinifiedFromSourceDataProvider
         * @test
         */
-       public function isJqueryLoadedMinifiedFromSourceByDefault($version, $cdn, $regex) {
-               $this->fixture->loadJquery($version, $cdn);
-               $out = $this->fixture->render();
-               $this->assertRegExp($regex, $out);
-       }
+       public function addInlineLanguageLabelFileSetsInlineLanguageLabelFiles() {
+               /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
+               $fileReference = uniqid('file_');
+               $selectionPrefix = uniqid('prefix_');
+               $stripFromSelectionName = uniqid('strip_');
+               $errorMode = 0;
 
-       /**
-        * test load ExtJS
-        */
-       public function testLoadExtJS() {
-               $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';
-               $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test load ExtCore
-        */
-       public function testLoadExtCore() {
-               $expectedRegExp = '#<script src="contrib/extjs/ext-core\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $this->fixture->loadExtCore();
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test enable ExtJsDebug
-        */
-       public function testEnableExtJsDebug() {
-               $expectedRegExp = '#<script src="contrib/extjs/ext-all-debug\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $this->fixture->loadExtJS(TRUE, TRUE, 'jquery');
-               $this->fixture->enableExtJsDebug();
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test enable ExtCoreDebug
-        */
-       public function testEnableExtCoreDebug() {
-               $expectedRegExp = '#<script src="contrib/extjs/ext-core-debug\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
-               $this->fixture->loadExtCore();
-               $this->fixture->enableExtCoreDebug();
-               $out = $this->fixture->render();
-               $this->assertRegExp($expectedRegExp, $out);
-       }
-
-       /**
-        * test inline language label
-        */
-       public function testAddInlineLanguageLabel() {
-               $expectedReturnValue = 'TYPO3.lang = {"myKey":"myValue"}';
-               $this->fixture->loadExtJS();
-               $this->fixture->addInlineLanguageLabel('myKey', 'myValue');
-               $this->fixture->enableMoveJsFromHeaderToFooter();
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test inline language label as array
-        */
-       public function testAddInlineLanguageLabelArray() {
-               $expectedReturnValue = 'TYPO3.lang = {"myKey1":"myValue1","myKey2":"myValue2"}';
-               $this->fixture->loadExtJS();
-               $this->fixture->addInlineLanguageLabelArray(array('myKey1' => 'myValue1', 'myKey2' => 'myValue2'));
-               $this->fixture->enableMoveJsFromHeaderToFooter();
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test inline language label as array get merged
-        */
-       public function testAddInlineLanguageLabelArrayMerged() {
-               $expectedReturnValue = 'TYPO3.lang = {"myKey1":"myValue1","myKey2":"myValue2"}';
-               $this->fixture->loadExtJS();
-               $this->fixture->addInlineLanguageLabelArray(array('myKey1' => 'myValue1'));
-               $this->fixture->addInlineLanguageLabelArray(array('myKey2' => 'myValue2'));
-               $this->fixture->enableMoveJsFromHeaderToFooter();
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test inline setting
-        */
-       public function testAddInlineSetting() {
-               $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey":"myValue"}};';
-               $this->fixture->loadExtJS();
-               $this->fixture->addInlineSetting('myApp', 'myKey', 'myValue');
-               $this->fixture->enableMoveJsFromHeaderToFooter();
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test inline settings with array
-        */
-       public function testAddInlineSettingArray() {
-               $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey1":"myValue1","myKey2":"myValue2"}};';
-               $this->fixture->loadExtJS();
-               $this->fixture->addInlineSettingArray('myApp', array('myKey1' => 'myValue1', 'myKey2' => 'myValue2'));
-               $this->fixture->enableMoveJsFromHeaderToFooter();
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
-
-       /**
-        * test inline settings with array get merged
-        */
-       public function testAddInlineSettingArrayMerged() {
-               $expectedReturnValue = 'TYPO3.settings = {"myApp":{"myKey1":"myValue1","myKey2":"myValue2"}};';
-               $this->fixture->loadExtJS();
-               $this->fixture->addInlineSettingArray('myApp', array('myKey1' => 'myValue1'));
-               $this->fixture->addInlineSettingArray('myApp', array('myKey2' => 'myValue2'));
-               $this->fixture->enableMoveJsFromHeaderToFooter();
-               $out = $this->fixture->render(\TYPO3\CMS\Core\Page\PageRenderer::PART_FOOTER);
-               $this->assertContains($expectedReturnValue, $out);
-       }
+               $expectedInlineLanguageLabelFile = array(
+                       'fileRef' => $fileReference,
+                       'selectionPrefix' => $selectionPrefix,
+                       'stripFromSelectionName' => $stripFromSelectionName,
+                       'errorMode' => $errorMode
+               );
 
-       /**
-        * test add body content
-        */
-       public function testAddBodyContent() {
-               $expectedReturnValue = 'ABCDE';
-               $this->fixture->addBodyContent('A');
-               $this->fixture->addBodyContent('B');
-               $this->fixture->addBodyContent('C');
-               $this->fixture->addBodyContent('D');
-               $this->fixture->addBodyContent('E');
-               $out = $this->fixture->getBodyContent();
-               $this->assertEquals($expectedReturnValue, $out);
-       }
+               $subject->addInlineLanguageLabelFile($fileReference, $selectionPrefix, $stripFromSelectionName, $errorMode);
+               $actualResult = $subject->getInlineLanguageLabelFiles();
 
-       /**
-        * test set body content
-        */
-       public function testSetBodyContent() {
-               $expectedReturnValue = 'ABCDE';
-               $this->fixture->setBodyContent('ABCDE');
-               $out = $this->fixture->getBodyContent();
-               $this->assertEquals($expectedReturnValue, $out);
-               $out = $this->fixture->render();
-               $this->assertContains($expectedReturnValue, $out);
+               $this->assertSame($expectedInlineLanguageLabelFile, array_pop($actualResult));
        }
 
        /**
-        * Tests the addInlineLanguageLabelFile() method.
-        *
         * @test
-        * @expectedException \RuntimeException
         */
-       public function areInlineLanguageLabelsNotProcessable() {
-               $this->fixture->setLanguage(NULL);
-               $this->fixture->addInlineLanguageLabelFile('EXT:lang/locallang_core.xlf');
-               $out = $this->fixture->render();
-       }
+       public function addInlineLanguageLabelFileSetsTwoDifferentInlineLanguageLabelFiles() {
+               /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
+               $fileReference1 = uniqid('file1_');
+               $selectionPrefix1 = uniqid('prefix1_');
+               $stripFromSelectionName1 = uniqid('strip1_');
+               $errorMode1 = 0;
+               $expectedInlineLanguageLabelFile1 = array(
+                       'fileRef' => $fileReference1,
+                       'selectionPrefix' => $selectionPrefix1,
+                       'stripFromSelectionName' => $stripFromSelectionName1,
+                       'errorMode' => $errorMode1
+               );
+               $fileReference2 = uniqid('file2_');
+               $selectionPrefix2 = uniqid('prefix2_');
+               $stripFromSelectionName2 = uniqid('strip2_');
+               $errorMode2 = 0;
+               $expectedInlineLanguageLabelFile2 = array(
+                       'fileRef' => $fileReference2,
+                       'selectionPrefix' => $selectionPrefix2,
+                       'stripFromSelectionName' => $stripFromSelectionName2,
+                       'errorMode' => $errorMode2
+               );
 
-       /**
-        * Tests the addInlineLanguageLabelFile() method.
-        *
-        * @test
-        */
-       public function areInlineLanguageLabelsPassed() {
-               $this->fixture->setLanguage($GLOBALS['LANG']->lang);
-               $this->fixture->addInlineLanguageLabelFile('EXT:lang/locallang_core.xlf');
-               $out = $this->fixture->render();
-               $this->assertContains('labels.beUser', $out);
-               $this->assertContains('labels.feUser', $out);
-       }
+               $subject->addInlineLanguageLabelFile($fileReference1, $selectionPrefix1, $stripFromSelectionName1, $errorMode1);
+               $subject->addInlineLanguageLabelFile($fileReference2, $selectionPrefix2, $stripFromSelectionName2, $errorMode2);
+               $actualResult = $subject->getInlineLanguageLabelFiles();
 
-       /**
-        * Tests the addInlineLanguageLabelFile() method.
-        *
-        * @test
-        */
-       public function areInlineLanguageLabelsEmptyOnNonExistingFile() {
-               $this->fixture->addInlineLanguageLabelFile('');
-               $inlineLanguageLabelFiles = $this->fixture->getInlineLanguageLabelFiles();
-               $this->assertEquals(array(), $inlineLanguageLabelFiles);
+               $this->assertSame($expectedInlineLanguageLabelFile2, array_pop($actualResult));
+               $this->assertSame($expectedInlineLanguageLabelFile1, array_pop($actualResult));
        }
 
        /**
-        * Tests the addInlineLanguageLabelFile() method.
-        *
         * @test
         */
-       public function areInlineLanguageLabelsSelected() {
-               $this->fixture->setLanguage($GLOBALS['LANG']->lang);
-               $this->fixture->addInlineLanguageLabelFile('EXT:lang/locallang_core.xlf', 'labels.');
-               $out = $this->fixture->render();
-               $this->assertContains('labels.beUser', $out);
-               $this->assertContains('labels.feUser', $out);
-       }
+       public function addInlineLanguageLabelFileDoesNotSetSameLanguageFileTwice() {
+               /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Page\\PageRenderer', array('dummy'), array(), '', FALSE);
+               $fileReference = uniqid('file2_');
+               $selectionPrefix = uniqid('prefix2_');
+               $stripFromSelectionName = uniqid('strip2_');
+               $errorMode = 0;
 
-       /**
-        * Tests the addInlineLanguageLabelFile() method.
-        *
-        * @test
-        */
-       public function areInlineLanguageLabelsSelectedAndStripped() {
-               $this->fixture->setLanguage($GLOBALS['LANG']->lang);
-               $this->fixture->addInlineLanguageLabelFile('EXT:lang/locallang_core.xlf', 'labels.', 'lock');
-               $out = $this->fixture->render();
-               $this->assertContains('edRecord', $out);
-               $this->assertContains('edRecord_content', $out);
-               $this->assertContains('edRecordUser', $out);
+               $subject->addInlineLanguageLabelFile($fileReference, $selectionPrefix, $stripFromSelectionName, $errorMode);
+               $subject->addInlineLanguageLabelFile($fileReference, $selectionPrefix, $stripFromSelectionName, $errorMode);
+               $this->assertSame(1, count($subject->getInlineLanguageLabelFiles()));
        }
-
-}
+}
\ No newline at end of file