[BUGFIX] Integrity test fails 47/19447/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 30 Mar 2013 13:13:39 +0000 (14:13 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 30 Mar 2013 13:26:02 +0000 (14:26 +0100)
The integerity test checks if TYPO3_DB is a resource. After switch to
mysqli, this is now an object and thus reflected with the patch now.
At the same time, the $link property - while it changed its type - is
now made protected, and a getter / setter is added.

Change-Id: I5ecdcc27f628352a26a51fc28d5a9d7be5e16315
Resolves: #46805
Related: #36419
Releases: 6.1
Reviewed-on: https://review.typo3.org/19447
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Database/DatabaseConnection.php
typo3/sysext/core/Tests/Integrity/IntegrityTest.php
typo3/sysext/core/Tests/Unit/Database/DatabaseConnectionTest.php
typo3/sysext/core/Tests/Unit/Database/PreparedStatementTest.php
typo3/sysext/core/Tests/Unit/Log/Writer/DatabaseTest.php

index e4797e3..a1d7f38 100644 (file)
@@ -94,11 +94,10 @@ class DatabaseConnection {
         */
        public $explainOutput = 0;
 
-       // Default link identifier:
        /**
-        * @todo Define visibility
+        * @var \mysqli $link Default database link object
         */
-       public $link = FALSE;
+       protected $link = NULL;
 
        // Default character set, applies unless character set or collation are explicitly set
        /**
@@ -1334,7 +1333,25 @@ class DatabaseConnection {
         * @return boolean
         */
        public function isConnected() {
-               return is_resource($this->link);
+               return is_object($this->link);
+       }
+
+       /**
+        * Returns current database handle
+        *
+        * @return \mysqli|NULL
+        */
+       public function getDatabaseHandle() {
+               return $this->link;
+       }
+
+       /**
+        * Set current database handle, usually \mysqli
+        *
+        * @param \mysqli $handle
+        */
+       public function setDatabaseHandle($handle) {
+               $this->link = $handle;
        }
 
        /******************************
index e2e9126..4baace7 100644 (file)
@@ -43,8 +43,8 @@ class IntegrityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         *
         * @test
         */
-       public function globalsTypo3DbDatabaseLinkIsAResource() {
-               $this->assertTrue(is_resource($GLOBALS['TYPO3_DB']->link));
+       public function globalsTypo3DbDatabaseLinkIsAObject() {
+               $this->assertTrue(is_object($GLOBALS['TYPO3_DB']->getDatabaseHandle()));
        }
 
        /**
index bf71435..16aa242 100644 (file)
@@ -34,9 +34,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @var \TYPO3\CMS\Core\Database\DatabaseConnection
         */
-       private $fixture = NULL;
+       protected $fixture = NULL;
 
-       private $testTable;
+       protected $testTable;
 
        public function setUp() {
                $this->fixture = $GLOBALS['TYPO3_DB'];
@@ -249,7 +249,6 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $strippedQuery = $this->fixture->stripGroupBy($groupByClause);
                $this->assertEquals($expectedResult, $strippedQuery);
        }
-
 }
 
 ?>
\ No newline at end of file
index fda6f38..6e6244a 100644 (file)
@@ -74,9 +74,9 @@ class PreparedStatementTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return \PHPUnit_Framework_MockObject_MockObject
         */
        private function setUpAndReturnDatabaseStub() {
-               $databaseLink = $GLOBALS['TYPO3_DB']->link;
+               $databaseLink = $GLOBALS['TYPO3_DB']->getDatabaseHandle();
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_PREPAREDquery'), array(), '', FALSE, FALSE);
-               $GLOBALS['TYPO3_DB']->link = $databaseLink;
+               $GLOBALS['TYPO3_DB']->setDatabaseHandle($databaseLink);
                return $GLOBALS['TYPO3_DB'];
        }
 
index bd0184f..0c64adf 100644 (file)
@@ -74,9 +74,9 @@ class DatabaseTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @return PHPUnit_Framework_MockObject_MockObject
         */
        private function setUpAndReturnDatabaseStub() {
-               $databaseLink = $GLOBALS['TYPO3_DB']->link;
+               $databaseLink = $GLOBALS['TYPO3_DB']->getDatabaseHandle();
                $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('exec_INSERTquery'), array(), '', FALSE, FALSE);
-               $GLOBALS['TYPO3_DB']->link = $databaseLink;
+               $GLOBALS['TYPO3_DB']->setDatabaseHandle($databaseLink);
                return $GLOBALS['TYPO3_DB'];
        }