[TASK] Tests: Remove backup of TYPO3_DB 26/27526/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 10 Feb 2014 15:09:13 +0000 (16:09 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 10 Feb 2014 15:43:48 +0000 (16:43 +0100)
All $GLOBALS are backed up by phpunit, no explicit backup
of $GLOBALS['TYPO3_DB'] is required.

Change-Id: I2859a5922d85a23fa8281382b1d78043ec7bd934
Resolves: #55846
Related: #51436
Releases: 6.2
Reviewed-on: https://review.typo3.org/27526
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/backend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/core/Tests/Unit/Resource/Repository/AbstractRepositoryTest.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionMssqlTest.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionOracleTest.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionPostgresqlTest.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionTest.php
typo3/sysext/extbase/Tests/Unit/Configuration/BackendConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php
typo3/sysext/extbase/Tests/Unit/Utility/ExtensionUtilityTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/Page/PageRepositoryTest.php

index 6a648a4..04f53e6 100644 (file)
@@ -34,11 +34,6 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @var array
         */
-       private $backupGlobalVariables;
-
-       /**
-        * @var array
-        */
        private $rootline;
 
        /**
@@ -52,18 +47,6 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        private $testTableName;
 
        public function setUp() {
-               $this->backupGlobalVariables = array(
-                       '_ENV' => $_ENV,
-                       '_GET' => $_GET,
-                       '_POST' => $_POST,
-                       '_SERVER' => $_SERVER,
-                       'TCA' => $GLOBALS['TCA'],
-                       'TYPO3_DB' => $GLOBALS['TYPO3_DB'],
-                       'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
-                       'T3_VAR' => $GLOBALS['T3_VAR'],
-                       'BE_USER' => $GLOBALS['BE_USER'],
-                       'SOBE' => $GLOBALS['SOBE']
-               );
                $this->testTableName = 'TYPO3\\CMS\\Backend\\Configuration\\TypoScript\\ConditionMatching\\ConditionMatcher_testTable';
                $this->testGlobalNamespace = uniqid('TEST');
                $GLOBALS['TCA'][$this->testTableName] = array('ctrl' => array());
@@ -73,11 +56,7 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        public function tearDown() {
-               foreach ($this->backupGlobalVariables as $key => $data) {
-                       $GLOBALS[$key] = $data;
-               }
                unset($this->matchCondition);
-               unset($this->backupGlobalVariables);
                unset($GLOBALS[$this->testGlobalNamespace]);
        }
 
index 849cdcd..0bac403 100644 (file)
@@ -41,11 +41,8 @@ class AbstractRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        private $mockedDb;
 
-       private $Typo3DbBackup;
-
        protected function createDatabaseMock() {
                $this->mockedDb = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
-               $this->Typo3DbBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->mockedDb;
        }
 
@@ -53,12 +50,6 @@ class AbstractRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->fixture = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractRepository', array(), '', FALSE);
        }
 
-       public function tearDown() {
-               if ($this->mockedDb) {
-                       $GLOBALS['TYPO3_DB'] = $this->Typo3DbBackup;
-               }
-       }
-
        /**
         * @test
         */
index 6f4b337..8e7c1d7 100644 (file)
@@ -9,23 +9,9 @@ namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $db;
-
-       /**
-        * @var array
-        */
-       protected $dbalConfig;
-
-       /**
         * Prepares the environment before running a test.
         */
        public function setUp() {
-               // Backup DBAL configuration
-               $this->dbalConfig = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'];
-               // Backup database connection
-               $this->db = $GLOBALS['TYPO3_DB'];
                // Reconfigure DBAL to use MS SQL
                require __DIR__ . '/Fixtures/mssql.config.php';
                $className = self::buildAccessibleProxy('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection');
@@ -44,10 +30,6 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function tearDown() {
                // Clear DBAL-generated cache files
                $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               // Restore DBAL configuration
-               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'] = $this->dbalConfig;
-               // Restore DB connection
-               $GLOBALS['TYPO3_DB'] = $this->db;
        }
 
        /**
index e38e0ea..c039b3a 100644 (file)
@@ -9,23 +9,9 @@ namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $db;
-
-       /**
-        * @var array
-        */
-       protected $dbalConfig;
-
-       /**
         * Prepares the environment before running a test.
         */
        public function setUp() {
-               // Backup DBAL configuration
-               $this->dbalConfig = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'];
-               // Backup database connection
-               $this->db = $GLOBALS['TYPO3_DB'];
                // Reconfigure DBAL to use Oracle
                require __DIR__ . '/Fixtures/oci8.config.php';
                $className = self::buildAccessibleProxy('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection');
@@ -44,10 +30,6 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function tearDown() {
                // Clear DBAL-generated cache files
                $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               // Restore DBAL configuration
-               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'] = $this->dbalConfig;
-               // Restore DB connection
-               $GLOBALS['TYPO3_DB'] = $this->db;
        }
 
        /**
index 8b01d5d..afa8c49 100644 (file)
@@ -9,23 +9,9 @@ namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $db;
-
-       /**
-        * @var array
-        */
-       protected $dbalConfig;
-
-       /**
         * Prepares the environment before running a test.
         */
        public function setUp() {
-               // Backup DBAL configuration
-               $this->dbalConfig = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'];
-               // Backup database connection
-               $this->db = $GLOBALS['TYPO3_DB'];
                // Reconfigure DBAL to use PostgreSQL
                require __DIR__ . '/Fixtures/postgresql.config.php';
                $className = self::buildAccessibleProxy('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection');
@@ -44,10 +30,6 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
        public function tearDown() {
                // Clear DBAL-generated cache files
                $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               // Restore DBAL configuration
-               $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal'] = $this->dbalConfig;
-               // Restore DB connection
-               $GLOBALS['TYPO3_DB'] = $this->db;
        }
 
        /**
index 1ad6e5a..bcfb8fe 100644 (file)
@@ -9,16 +9,6 @@ namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $db;
-
-       /**
-        * @var array
-        */
-       protected $loadedExtensions;
-
-       /**
         * @var array
         */
        protected $temporaryFiles;
@@ -27,10 +17,6 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * Prepares the environment before running a test.
         */
        public function setUp() {
-               // Backup list of loaded extensions
-//             $this->loadedExtensions = $GLOBALS['TYPO3_LOADED_EXT'];
-               // Backup database connection
-               $this->db = $GLOBALS['TYPO3_DB'];
                $this->temporaryFiles = array();
                $className = self::buildAccessibleProxy('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection');
                $GLOBALS['TYPO3_DB'] = new $className();
@@ -47,10 +33,6 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                foreach ($this->temporaryFiles as $filename) {
                        unlink($filename);
                }
-               // Restore DB connection
-               $GLOBALS['TYPO3_DB'] = $this->db;
-               // Restore list of loaded extensions
-//             $GLOBALS['TYPO3_LOADED_EXT'] = $this->loadedExtensions;
        }
 
        /**
index ceace03..5bc3d8f 100644 (file)
@@ -30,11 +30,6 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Configuration;
 class BackendConfigurationManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $typo3DbBackup;
-
-       /**
         * @var \TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
        protected $backendConfigurationManager;
@@ -48,7 +43,6 @@ class BackendConfigurationManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
         * Sets up this testcase
         */
        public function setUp() {
-               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array());
                $this->backendConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager', array('getTypoScriptSetup'));
                $this->mockTypoScriptService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
@@ -56,13 +50,6 @@ class BackendConfigurationManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\Base
        }
 
        /**
-        * Tears down this testcase
-        */
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
-       }
-
-       /**
         * @test
         */
        public function getCurrentPageIdReturnsPageIdFromGet() {
index ac1d9a2..163c65d 100644 (file)
@@ -29,11 +29,6 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Service;
 class ExtensionServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $typo3DbBackup;
-
-       /**
         * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
         */
        protected $mockConfigurationManager;
@@ -44,7 +39,6 @@ class ExtensionServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
        protected $extensionService;
 
        public function setUp() {
-               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('fullQuoteStr', 'exec_SELECTgetRows'));
                $GLOBALS['TSFE'] = new \stdClass();
                $this->extensionService = $this->getAccessibleMock('TYPO3\CMS\Extbase\Service\ExtensionService', array('dummy'));
@@ -87,10 +81,6 @@ class ExtensionServiceTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                );
        }
 
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
-       }
-
        /**
         * DataProvider for getPluginNamespaceByPluginSignatureTests()
         *
index bb6e9e3..f9a05db 100644 (file)
@@ -28,15 +28,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Utility;
  */
 class ExtensionUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
-       /**
-        * A backup of the global database
-        *
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $databaseBackup = NULL;
-
        public function setUp() {
-               $this->databaseBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('fullQuoteStr', 'exec_SELECTgetRows'));
 
                $GLOBALS['TSFE'] = new \stdClass();
@@ -71,10 +63,6 @@ class ExtensionUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                );
        }
 
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->databaseBackup;
-       }
-
        /**
         * @test
         * @see \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin
index c9f06b9..177f7e6 100644 (file)
@@ -31,13 +31,6 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu;
 class AbstractMenuContentObjectTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
-        * A backup of the global database
-        *
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $databaseBackup = NULL;
-
-       /**
         * @var \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject
         */
        protected $fixture = NULL;
@@ -48,20 +41,12 @@ class AbstractMenuContentObjectTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTe
        public function setUp() {
                $proxy = $this->buildAccessibleProxy('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\AbstractMenuContentObject');
                $this->fixture = new $proxy();
-               $this->databaseBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
                $GLOBALS['TSFE'] = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array($GLOBALS['TYPO3_CONF_VARS'], 1, 1));
                $GLOBALS['TSFE']->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
                $GLOBALS['TSFE']->page = array();
        }
 
-       /**
-        * Tear down this testcase
-        */
-       public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->databaseBackup;
-       }
-
        ////////////////////////////////
        // Tests concerning sectionIndex
        ////////////////////////////////
index 5e9f4c3..8492597 100644 (file)
@@ -32,11 +32,6 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Page;
 class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        /**
-        * @var \TYPO3\CMS\Core\Database\DatabaseConnection
-        */
-       protected $typo3DbBackup;
-
-       /**
         * @var \TYPO3\CMS\Frontend\Page\PageRepository|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
        protected $pageSelectObject;
@@ -45,7 +40,6 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * Sets up this testcase
         */
        public function setUp() {
-               $this->typo3DbBackup = $GLOBALS['TYPO3_DB'];
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_SELECTquery', 'sql_fetch_assoc', 'sql_free_result'));
                $this->pageSelectObject = $this->getAccessibleMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository', array('getMultipleGroupsWhereClause'));
                $this->pageSelectObject->expects($this->any())->method('getMultipleGroupsWhereClause')->will($this->returnValue(' AND 1=1'));
@@ -55,7 +49,6 @@ class PageRepositoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * Tears down this testcase
         */
        public function tearDown() {
-               $GLOBALS['TYPO3_DB'] = $this->typo3DbBackup;
                unset($this->pageSelectObject);
        }