[BUGFIX] Tests: Incomplete mocking of $GLOBALS['TCA'] in ext:frontend 04/28204/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 9 Mar 2014 22:28:24 +0000 (23:28 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Sun, 9 Mar 2014 22:46:41 +0000 (23:46 +0100)
To reduce dependencies of tests and improve readability, some tests
can be improved by better mocking of $GLOBALS['TCA'].

Change-Id: Ib38f2dd94288c5c4f8940d3c8c969ea0459ebbcb
Resolves: #56698
Related: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/28204
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php

index 03222fb..ac73514 100644 (file)
@@ -1229,6 +1229,23 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function getQuery($table, $conf, $expected) {
+               $GLOBALS['TCA'] = array(
+                       'pages' => array(
+                               'ctrl' => array(
+                                       'enablecolumns' => array(
+                                               'disabled' => 'hidden'
+                                       )
+                               )
+                       ),
+                       'tt_content' => array(
+                               'ctrl' => array(
+                                       'enablecolumns' => array(
+                                               'disabled' => 'hidden'
+                                       ),
+                                       'versioningWS' => 2
+                               )
+                       ),
+               );
                $result = $this->cObj->getQuery($table, $conf, TRUE);
                foreach ($expected as $field => $value) {
                        $this->assertEquals($value, $result[$field]);
@@ -1239,6 +1256,22 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function getQueryCallsGetTreeListWithNegativeValuesIfRecursiveIsSet() {
+               $GLOBALS['TCA'] = array(
+                       'pages' => array(
+                               'ctrl' => array(
+                                       'enablecolumns' => array(
+                                               'disabled' => 'hidden'
+                                       )
+                               )
+                       ),
+                       'tt_content' => array(
+                               'ctrl' => array(
+                                       'enablecolumns' => array(
+                                               'disabled' => 'hidden'
+                                       )
+                               )
+                       ),
+               );
                $this->cObj = $this->getAccessibleMock('\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array('getTreeList'));
                $this->cObj->start(array(), 'tt_content');
                $conf = array(
@@ -1258,6 +1291,22 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function getQueryCallsGetTreeListWithCurrentPageIfThisIsSet() {
+               $GLOBALS['TCA'] = array(
+                       'pages' => array(
+                               'ctrl' => array(
+                                       'enablecolumns' => array(
+                                               'disabled' => 'hidden'
+                                       )
+                               )
+                       ),
+                       'tt_content' => array(
+                               'ctrl' => array(
+                                       'enablecolumns' => array(
+                                               'disabled' => 'hidden'
+                                       )
+                               )
+                       ),
+               );
                $this->cObj = $this->getAccessibleMock('\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array('getTreeList'));
                $GLOBALS['TSFE']->id = 27;
                $this->cObj->start(array(), 'tt_content');
index 4e5c695..ee742b9 100644 (file)
@@ -244,52 +244,88 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function enableFieldsHidesVersionedRecordsAndPlaceholders() {
+               $table = uniqid('aTable');
+               $GLOBALS['TCA'] = array(
+                       $table => array(
+                               'ctrl' => array(
+                                       'versioningWS' => 2
+                               )
+                       )
+               );
+
                $this->pageSelectObject->versioningPreview = FALSE;
                $this->pageSelectObject->init(FALSE);
 
-               $conditions = $this->pageSelectObject->enableFields('tt_content');
+               $conditions = $this->pageSelectObject->enableFields($table);
 
-               $this->assertThat($conditions, $this->stringContains(' AND tt_content.t3ver_state<=0'), 'Versioning placeholders');
-               $this->assertThat($conditions, $this->stringContains(' AND tt_content.pid<>-1'), 'Records from page -1');
+               $this->assertThat($conditions, $this->stringContains(' AND ' . $table . '.t3ver_state<=0'), 'Versioning placeholders');
+               $this->assertThat($conditions, $this->stringContains(' AND ' . $table . '.pid<>-1'), 'Records from page -1');
        }
 
        /**
         * @test
         */
        public function enableFieldsDoesNotHidePlaceholdersInPreview() {
+               $table = uniqid('aTable');
+               $GLOBALS['TCA'] = array(
+                       $table => array(
+                               'ctrl' => array(
+                                       'versioningWS' => 2
+                               )
+                       )
+               );
+
                $this->pageSelectObject->versioningPreview = TRUE;
                $this->pageSelectObject->init(FALSE);
 
-               $conditions = $this->pageSelectObject->enableFields('tt_content');
+               $conditions = $this->pageSelectObject->enableFields($table);
 
-               $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND tt_content.t3ver_state<=0')), 'No versioning placeholders');
-               $this->assertThat($conditions, $this->stringContains(' AND tt_content.pid<>-1'), 'Records from page -1');
+               $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.t3ver_state<=0')), 'No versioning placeholders');
+               $this->assertThat($conditions, $this->stringContains(' AND ' . $table . '.pid<>-1'), 'Records from page -1');
        }
 
        /**
         * @test
         */
        public function enableFieldsDoesFilterToCurrentAndLiveWorkspaceForRecordsInPreview() {
+               $table = uniqid('aTable');
+               $GLOBALS['TCA'] = array(
+                       $table => array(
+                               'ctrl' => array(
+                                       'versioningWS' => 2
+                               )
+                       )
+               );
+
                $this->pageSelectObject->versioningPreview = TRUE;
                $this->pageSelectObject->versioningWorkspaceId = 2;
                $this->pageSelectObject->init(FALSE);
 
-               $conditions = $this->pageSelectObject->enableFields('tt_content');
+               $conditions = $this->pageSelectObject->enableFields($table);
 
-               $this->assertThat($conditions, $this->stringContains(' AND (tt_content.t3ver_wsid=0 OR tt_content.t3ver_wsid=2)'), 'No versioning placeholders');
+               $this->assertThat($conditions, $this->stringContains(' AND (' . $table . '.t3ver_wsid=0 OR ' . $table . '.t3ver_wsid=2)'), 'No versioning placeholders');
        }
 
        /**
         * @test
         */
        public function enableFieldsDoesNotHideVersionedRecordsWhenCheckingVersionOverlays() {
+               $table = uniqid('aTable');
+               $GLOBALS['TCA'] = array(
+                       $table => array(
+                               'ctrl' => array(
+                                       'versioningWS' => 2
+                               )
+                       )
+               );
+
                $this->pageSelectObject->versioningPreview = TRUE;
                $this->pageSelectObject->init(FALSE);
 
-               $conditions = $this->pageSelectObject->enableFields('tt_content', -1, array(), TRUE     );
+               $conditions = $this->pageSelectObject->enableFields($table, -1, array(), TRUE   );
 
-               $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND tt_content.t3ver_state<=0')), 'No versioning placeholders');
-               $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND tt_content.pid<>-1')), 'No ecords from page -1');
+               $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.t3ver_state<=0')), 'No versioning placeholders');
+               $this->assertThat($conditions, $this->logicalNot($this->stringContains(' AND ' . $table . '.pid<>-1')), 'No ecords from page -1');
        }