[TASK] Tests: Refactor and activate dbal tests 74/29874/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 5 May 2014 15:21:49 +0000 (17:21 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Mon, 5 May 2014 16:17:43 +0000 (18:17 +0200)
Our unit test environment is finally ready to execute existing dbal
unit tests, even if no database connection exists.

The patch refactors unit tests of ext:dbal, modernizes their codebase
and adds them to the build.

Resolves: #52527
Related: #51436
Releases: 6.2
Change-Id: I70507591dc89331d658d50196dfcaea002caa7d5
Reviewed-on: https://review.typo3.org/29874
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Build/UnitTests.xml
typo3/sysext/dbal/Tests/Unit/Database/AbstractTestCase.php [new file with mode: 0644]
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/dbal/Tests/Unit/Database/FakeDatabaseConnection.php [deleted file]
typo3/sysext/dbal/Tests/Unit/Database/Fixtures/mssql.config.php [deleted file]
typo3/sysext/dbal/Tests/Unit/Database/Fixtures/oci8.config.php [deleted file]
typo3/sysext/dbal/Tests/Unit/Database/Fixtures/postgresql.config.php [deleted file]
typo3/sysext/dbal/Tests/Unit/Database/SqlParserTest.php

index 7518119..1b88a0c 100644 (file)
@@ -36,6 +36,9 @@
                <testsuite name="EXT:documentation tests">
                        <directory>../../../../typo3/sysext/documentation/Tests/Unit/</directory>
                </testsuite>
+               <testsuite name="EXT:dbal tests">
+                       <directory>../../../../typo3/sysext/dbal/Tests/Unit/</directory>
+               </testsuite>
                <testsuite name="EXT:extbase tests">
                        <directory>../../../../typo3/sysext/extbase/Tests/Unit/</directory>
                </testsuite>
diff --git a/typo3/sysext/dbal/Tests/Unit/Database/AbstractTestCase.php b/typo3/sysext/dbal/Tests/Unit/Database/AbstractTestCase.php
new file mode 100644 (file)
index 0000000..077e705
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
+
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2014 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!
+ ***************************************************************/
+
+require_once __DIR__ . '/../../../../adodb/adodb/adodb.inc.php';
+require_once __DIR__ . '/../../../../adodb/adodb/drivers/adodb-mssql.inc.php';
+require_once __DIR__ . '/../../../../adodb/adodb/drivers/adodb-oci8.inc.php';
+require_once __DIR__ . '/../../../../adodb/adodb/drivers/adodb-postgres7.inc.php';
+
+/**
+ * Base test case for dbal database tests.
+ */
+abstract class AbstractTestCase extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+
+       /**
+        * Prepare a DatabaseConnection subject.
+        * Used by driver specific test cases.
+        *
+        * @param string $driver Driver to use like "mssql", "oci8" and "postgres7"
+        * @param array $configuration Dbal configuration array
+        * @return \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
+        */
+       protected function prepareSubject($driver, array $configuration) {
+               /** @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('getFieldInfoCache'), array(), '', FALSE);
+
+               $subject->conf = $configuration;
+
+               // Disable caching
+               $mockCacheFrontend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
+               $subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend));
+
+               // Inject SqlParser - Its logic is tested with the tests, too.
+               $sqlParser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'), array(), '', FALSE);
+               $sqlParser->_set('databaseConnection', $subject);
+               $subject->SQLparser = $sqlParser;
+
+               // Mock away schema migration service from install tool
+               $installerSqlMock = $this->getMock('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService', array('getFieldDefinitions_fileContent'), array(), '', FALSE);
+               $installerSqlMock->expects($this->any())->method('getFieldDefinitions_fileContent')->will($this->returnValue(array()));
+               $subject->_set('installerSql', $installerSqlMock);
+
+               $subject->initialize();
+
+               // Fake a working connection
+               $handlerKey = '_DEFAULT';
+               $subject->lastHandlerKey = $handlerKey;
+               $adodbDriverClass = '\ADODB_' . $driver;
+               $subject->handlerInstance[$handlerKey] = new $adodbDriverClass();
+               $subject->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($subject->handlerInstance[$handlerKey]);
+               $subject->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
+
+               return $subject;
+       }
+
+
+       /**
+        * Clean a parsed SQL query for easier comparison with expected SQL.
+        *
+        * @param mixed $sql
+        * @return mixed (string or array)
+        */
+       protected function cleanSql($sql) {
+               if (!is_string($sql)) {
+                       return $sql;
+               }
+               $sql = str_replace("\n", ' ', $sql);
+               $sql = preg_replace('/\\s+/', ' ', $sql);
+               return trim($sql);
+       }
+}
\ No newline at end of file
index a1a8afb..115c088 100644 (file)
@@ -1,74 +1,79 @@
 <?php
 namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 
-/**
- * Test MS SQL database handling.
+/***************************************************************
+ * Copyright notice
  *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+ * (c) 2010-2014 Xavier Perseguers <xavier@typo3.org>
+ * 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.
+ * A copy is found in the text file GPL.txt and important notices to the license
+ * from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ * 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!
+ ***************************************************************/
 
-       /**
-        * Prepares the environment before running a test.
-        */
-       public function setUp() {
-               // Reconfigure DBAL to use MS SQL
-               require __DIR__ . '/Fixtures/mssql.config.php';
-               $GLOBALS['TYPO3_DB'] = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('dummy'));
-               $GLOBALS['TYPO3_DB']->SQLparser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'));
-               $this->assertFalse($GLOBALS['TYPO3_DB']->isConnected());
-               // Initialize a fake MS SQL connection
-               \TYPO3\CMS\Dbal\Tests\Unit\Database\FakeDatabaseConnection::connect($GLOBALS['TYPO3_DB'], 'mssql');
-               $this->assertTrue($GLOBALS['TYPO3_DB']->isConnected());
-       }
+/**
+ * Test case
+ */
+class DatabaseConnectionMssqlTest extends AbstractTestCase {
 
        /**
-        * Cleans up the environment after running a test.
+        * @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
-       public function tearDown() {
-               // Clear DBAL-generated cache files
-               $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               parent::tearDown();
-       }
+       protected $subject;
 
        /**
-        * Cleans a SQL query.
+        * Prepare a DatabaseConnection subject ready to parse mssql queries
         *
-        * @param mixed $sql
-        * @return mixed (string or array)
-        */
-       private function cleanSql($sql) {
-               if (!is_string($sql)) {
-                       return $sql;
-               }
-               $sql = str_replace("\n", ' ', $sql);
-               $sql = preg_replace('/\\s+/', ' ', $sql);
-               return trim($sql);
-       }
-
-       /**
-        * @test
+        * @return \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
-       public function configurationIsUsingAdodbAndDriverMssql() {
-               $configuration = $GLOBALS['TYPO3_DB']->conf['handlerCfg'];
-               $this->assertTrue(is_array($configuration) && count($configuration) > 0, 'No configuration found');
-               $this->assertEquals('adodb', $configuration['_DEFAULT']['type']);
-               $this->assertTrue($GLOBALS['TYPO3_DB']->runningADOdbDriver('mssql') !== FALSE, 'Not using mssql driver');
+       public function setUp() {
+               $configuration = array(
+                       'handlerCfg' => array(
+                               '_DEFAULT' => array(
+                                       'type' => 'adodb',
+                                       'config' => array(
+                                               'driver' => 'mssql',
+                                       ),
+                               ),
+                       ),
+                       'mapping' => array(
+                               'tx_templavoila_tmplobj' => array(
+                                       'mapFieldNames' => array(
+                                               'datastructure' => 'ds',
+                                       ),
+                               ),
+                               'Members' => array(
+                                       'mapFieldNames' => array(
+                                               'pid' => '0',
+                                               'cruser_id' => '1',
+                                               'uid' => 'MemberID',
+                                       ),
+                               ),
+                       ),
+               );
+               $this->subject = $this->prepareSubject('mssql', $configuration);
        }
 
        /**
         * @test
         */
-       public function tablesWithMappingAreDetected() {
-               $tablesWithMapping = array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['mapping']);
-               foreach ($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fieldTypes) {
-                       $tableDef = $GLOBALS['TYPO3_DB']->_call('map_needMapping', $table);
-                       if (in_array($table, $tablesWithMapping)) {
-                               self::assertTrue(is_array($tableDef), 'Table ' . $table . ' was expected to need mapping');
-                       } else {
-                               self::assertFalse($tableDef, 'Table ' . $table . ' was not expected to need mapping');
-                       }
-               }
+       public function runningADOdbDriverReturnsTrueWithMssqlForMssqlDefaultDriverConfiguration() {
+               $this->assertTrue($this->subject->runningADOdbDriver('mssql'));
        }
 
        /**
@@ -76,9 +81,9 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/23087
         */
        public function findInSetIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)'));
                $expected = 'SELECT * FROM "fe_users" WHERE \',\'+"usergroup"+\',\' LIKE \'%,10,%\'';
-               $this->assertEquals($expected, $query);
+               $result = $this->subject->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)');
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -87,9 +92,10 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function canParseSingleQuote() {
                $parseString = 'SELECT * FROM pages WHERE title=\'1\'\'\' AND deleted=0';
-               $components = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('parseSELECT', $parseString);
+               $components = $this->subject->SQLparser->_callRef('parseSELECT', $parseString);
+
                $this->assertTrue(is_array($components), $components);
-               $this->assertTrue(empty($components['parseString']), 'parseString is not empty');
+               $this->assertEmpty($components['parseString']);
        }
 
        ///////////////////////////////////////
@@ -106,10 +112,11 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'pid=0 AND cruser_id=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "MemberID", "FirstName", "LastName" FROM "Members" WHERE 0 = 0 AND 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -120,9 +127,9 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21902
         */
        public function locateStatementIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1'));
+               $result = $this->subject->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1');
                $expected = 'SELECT *, CASE WHEN CHARINDEX(\'(fce)\', "datastructure") > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -130,9 +137,9 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21902
         */
        public function locateStatementWithPositionIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1'));
+               $result = $this->subject->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1');
                $expected = 'SELECT *, CASE WHEN CHARINDEX(\'(fce)\', "datastructure", 4) > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -140,15 +147,16 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21902
         */
        public function locateStatementIsProperlyRemapped() {
-               $selectFields = '*, CASE WHEN' . ' LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope';
+               $selectFields = '*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope';
                $fromTables = 'tx_templavoila_tmplobj';
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT *, CASE WHEN CHARINDEX(\'(fce)\', "ds", 4) > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -156,15 +164,16 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21902
         */
        public function locateStatementWithExternalTableIsProperlyRemapped() {
-               $selectFields = '*, CASE WHEN' . ' LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', tx_templavoila_tmplobj.datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope';
+               $selectFields = '*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', tx_templavoila_tmplobj.datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope';
                $fromTables = 'tx_templavoila_tmplobj';
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT *, CASE WHEN CHARINDEX(\'(fce)\', "tx_templavoila_tmplobj"."ds", 4) > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -172,9 +181,8 @@ class DatabaseConnectionMssqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/17552
         */
        public function IfNullIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_news_cat_mm', 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)'));
+               $result = $this->subject->SELECTquery('*', 'tt_news_cat_mm', 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)');
                $expected = 'SELECT * FROM "tt_news_cat_mm" WHERE ISNULL("tt_news_cat_mm"."uid_foreign", 0) IN (21,22)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
-
-}
+}
\ No newline at end of file
index f3a71bd..2acfb8a 100644 (file)
 <?php
 namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 
-/**
- * Test Oracle database handling.
+/***************************************************************
+ * Copyright notice
  *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+ * (c) 2010-2014 Xavier Perseguers <xavier@typo3.org>
+ * 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.
+ * A copy is found in the text file GPL.txt and important notices to the license
+ * from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ * 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!
+ ***************************************************************/
 
-       /**
-        * Prepares the environment before running a test.
-        */
-       public function setUp() {
-               // Reconfigure DBAL to use Oracle
-               require __DIR__ . '/Fixtures/oci8.config.php';
-               $GLOBALS['TYPO3_DB'] = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('dummy'));
-               $GLOBALS['TYPO3_DB']->SQLparser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'));
-               $this->assertFalse($GLOBALS['TYPO3_DB']->isConnected());
-               // Initialize a fake Oracle connection
-               \TYPO3\CMS\Dbal\Tests\Unit\Database\FakeDatabaseConnection::connect($GLOBALS['TYPO3_DB'], 'oci8');
-               $this->assertTrue($GLOBALS['TYPO3_DB']->isConnected());
-       }
+/**
+ * Test case
+ */
+class DatabaseConnectionOracleTest extends AbstractTestCase {
 
        /**
-        * Cleans up the environment after running a test.
+        * @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
-       public function tearDown() {
-               // Clear DBAL-generated cache files
-               $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               parent::tearDown();
-       }
+       protected $subject;
 
        /**
-        * Cleans a SQL query.
+        * Prepare a DatabaseConnection subject ready to parse oracle queries
         *
-        * @param mixed $sql
-        * @return mixed (string or array)
+        * @return void
         */
-       private function cleanSql($sql) {
-               if (!is_string($sql)) {
-                       return $sql;
-               }
-               $sql = str_replace('
-', ' ', $sql);
-               $sql = preg_replace('/\\s+/', ' ', $sql);
-               return trim($sql);
-       }
+       public function setUp() {
+               $configuration = array(
+                       'handlerCfg' => array(
+                               '_DEFAULT' => array(
+                                       'type' => 'adodb',
+                                       'config' => array(
+                                               'driver' => 'oci8',
+                                       ),
+                               ),
+                       ),
+                       'mapping' => array(
+                               'cachingframework_cache_hash' => array(
+                                       'mapTableName' => 'cf_cache_hash',
+                               ),
+                               'cachingframework_cache_hash_tags' => array(
+                                       'mapTableName' => 'cf_cache_hash_tags',
+                               ),
+                               'cachingframework_cache_pages' => array(
+                                       'mapTableName' => 'cf_cache_pages',
+                               ),
+                               'cpg_categories' => array(
+                                       'mapFieldNames' => array(
+                                               'pid' => 'page_id',
+                                       ),
+                               ),
+                               'pages' => array(
+                                       'mapTableName' => 'my_pages',
+                                       'mapFieldNames' => array(
+                                               'uid' => 'page_uid',
+                                       ),
+                               ),
+                               'tt_news' => array(
+                                       'mapTableName' => 'ext_tt_news',
+                                       'mapFieldNames' => array(
+                                               'uid' => 'news_uid',
+                                               'fe_group' => 'usergroup',
+                                       ),
+                               ),
+                               'tt_news_cat' => array(
+                                       'mapTableName' => 'ext_tt_news_cat',
+                                       'mapFieldNames' => array(
+                                               'uid' => 'cat_uid',
+                                       ),
+                               ),
+                               'tt_news_cat_mm' => array(
+                                       'mapTableName' => 'ext_tt_news_cat_mm',
+                                       'mapFieldNames' => array(
+                                               'uid_local' => 'local_uid',
+                                       ),
+                               ),
+                               'tx_crawler_process' => array(
+                                       'mapTableName' => 'tx_crawler_ps',
+                                       'mapFieldNames' => array(
+                                               'process_id' => 'ps_id',
+                                               'active' => 'is_active',
+                                       ),
+                               ),
+                               'tx_dam_file_tracking' => array(
+                                       'mapFieldNames' => array(
+                                               'file_name' => 'filename',
+                                               'file_path' => 'path',
+                                       ),
+                               ),
+                               'tx_dbal_debuglog' => array(
+                                       'mapFieldNames' => array(
+                                               'errorFlag' => 'errorflag',
+                                       ),
+                               ),
+                               'tx_templavoila_datastructure' => array(
+                                       'mapTableName' => 'tx_templavoila_ds',
+                               ),
+                       ),
+               );
 
-       /**
-        * @test
-        */
-       public function configurationIsUsingAdodbAndDriverOci8() {
-               $configuration = $GLOBALS['TYPO3_DB']->conf['handlerCfg'];
-               $this->assertTrue(is_array($configuration) && count($configuration) > 0, 'No configuration found');
-               $this->assertEquals('adodb', $configuration['_DEFAULT']['type']);
-               $this->assertTrue($GLOBALS['TYPO3_DB']->runningADOdbDriver('oci8') !== FALSE, 'Not using oci8 driver');
+               $this->subject = $this->prepareSubject('oci8', $configuration);
        }
 
        /**
         * @test
         */
-       public function tablesWithMappingAreDetected() {
-               $tablesWithMapping = array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['mapping']);
-               foreach ($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fieldTypes) {
-                       $tableDef = $GLOBALS['TYPO3_DB']->_call('map_needMapping', $table);
-                       if (in_array($table, $tablesWithMapping)) {
-                               self::assertTrue(is_array($tableDef), 'Table ' . $table . ' was expected to need mapping');
-                       } else {
-                               self::assertFalse($tableDef, 'Table ' . $table . ' was not expected to need mapping');
-                       }
-               }
+       public function runningADOdbDriverReturnsTrueWithOci8ForOci8DefaultDriverConfiguration() {
+               $this->assertTrue($this->subject->runningADOdbDriver('oci8'));
        }
 
        /**
@@ -77,9 +130,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21780
         */
        public function sqlHintIsRemoved() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('/*! SQL_NO_CACHE */ content', 'tx_realurl_urlencodecache', '1=1'));
+               $result = $this->subject->SELECTquery('/*! SQL_NO_CACHE */ content', 'tx_realurl_urlencodecache', '1=1');
                $expected = 'SELECT "content" FROM "tx_realurl_urlencodecache" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -88,9 +141,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function canCompileInsertWithFields() {
                $parseString = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
                $parseString .= 'VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\');';
-               $components = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('parseINSERT', $parseString);
+               $components = $this->subject->SQLparser->_callRef('parseINSERT', $parseString);
                $this->assertTrue(is_array($components), $components);
-               $insert = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('compileINSERT', $components);
+               $insert = $this->subject->SQLparser->_callRef('compileINSERT', $components);
                $expected = array(
                        'uid' => '1',
                        'pid' => '0',
@@ -106,11 +159,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function canCompileExtendedInsert() {
                $tableFields = array('uid', 'pid', 'tr_iso_nr', 'tr_parent_iso_nr', 'tr_name_en');
-               $GLOBALS['TYPO3_DB']->cache_fieldType['static_territories'] = array_flip($tableFields);
+               $this->subject->cache_fieldType['static_territories'] = array_flip($tableFields);
                $parseString = 'INSERT INTO static_territories VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\'),(\'2\', \'0\', \'9\', \'0\', \'Oceania\'),' . '(\'3\', \'0\', \'19\', \'0\', \'Americas\'),(\'4\', \'0\', \'142\', \'0\', \'Asia\');';
-               $components = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('parseINSERT', $parseString);
+               $components = $this->subject->SQLparser->_callRef('parseINSERT', $parseString);
                $this->assertTrue(is_array($components), $components);
-               $insert = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('compileINSERT', $components);
+               $insert = $this->subject->SQLparser->_callRef('compileINSERT', $components);
                $this->assertEquals(4, count($insert));
                for ($i = 0; $i < count($insert); $i++) {
                        foreach ($tableFields as $field) {
@@ -129,15 +182,15 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        array('3', '4', 'Title #2', 'Content #2'),
                        array('5', '6', 'Title #3', 'Content #3')
                );
-               $query = $GLOBALS['TYPO3_DB']->INSERTmultipleRows('tt_content', $fields, $rows);
+               $result = $this->subject->INSERTmultipleRows('tt_content', $fields, $rows);
                $expected[0] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'1\', \'2\', \'Title #1\', \'Content #1\' )';
                $expected[1] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'3\', \'4\', \'Title #2\', \'Content #2\' )';
                $expected[2] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'5\', \'6\', \'Title #3\', \'Content #3\' )';
-               $this->assertEquals(count($expected), count($query));
-               for ($i = 0; $i < count($query); $i++) {
-                       $this->assertTrue(is_array($query[$i]), 'Expected array: ' . $query[$i]);
-                       $this->assertEquals(1, count($query[$i]));
-                       $this->assertEquals($expected[$i], $this->cleanSql($query[$i][0]));
+               $this->assertEquals(count($expected), count($result));
+               for ($i = 0; $i < count($result); $i++) {
+                       $this->assertTrue(is_array($result[$i]), 'Expected array: ' . $result[$i]);
+                       $this->assertEquals(1, count($result[$i]));
+                       $this->assertEquals($expected[$i], $this->cleanSql($result[$i][0]));
                }
        }
 
@@ -146,9 +199,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/23431
         */
        public function groupConditionsAreProperlyTransformed() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'pages', 'pid=0 AND pages.deleted=0 AND pages.hidden=0 AND pages.starttime<=1281620460 ' . 'AND (pages.endtime=0 OR pages.endtime>1281620460) AND NOT pages.t3ver_state>0 ' . 'AND pages.doktype<200 AND (pages.fe_group=\'\' OR pages.fe_group IS NULL OR ' . 'pages.fe_group=\'0\' OR FIND_IN_SET(\'0\',pages.fe_group) OR FIND_IN_SET(\'-1\',pages.fe_group))'));
+               $result = $this->subject->SELECTquery('*', 'pages', 'pid=0 AND pages.deleted=0 AND pages.hidden=0 AND pages.starttime<=1281620460 ' . 'AND (pages.endtime=0 OR pages.endtime>1281620460) AND NOT pages.t3ver_state>0 ' . 'AND pages.doktype<200 AND (pages.fe_group=\'\' OR pages.fe_group IS NULL OR ' . 'pages.fe_group=\'0\' OR FIND_IN_SET(\'0\',pages.fe_group) OR FIND_IN_SET(\'-1\',pages.fe_group))');
                $expected = 'SELECT * FROM "pages" WHERE "pid" = 0 AND "pages"."deleted" = 0 AND "pages"."hidden" = 0 ' . 'AND "pages"."starttime" <= 1281620460 AND ("pages"."endtime" = 0 OR "pages"."endtime" > 1281620460) ' . 'AND NOT "pages"."t3ver_state" > 0 AND "pages"."doktype" < 200 AND ("pages"."fe_group" = \'\' ' . 'OR "pages"."fe_group" IS NULL OR "pages"."fe_group" = \'0\' OR \',\'||"pages"."fe_group"||\',\' LIKE \'%,0,%\' ' . 'OR \',\'||"pages"."fe_group"||\',\' LIKE \'%,-1,%\')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -158,18 +211,18 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function selectQueryIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('uid', 'tt_content', 'pid=1', 'cruser_id', 'tstamp'));
+               $result = $this->subject->SELECTquery('uid', 'tt_content', 'pid=1', 'cruser_id', 'tstamp');
                $expected = 'SELECT "uid" FROM "tt_content" WHERE "pid" = 1 GROUP BY "cruser_id" ORDER BY "tstamp"';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
         * @test
         */
        public function truncateQueryIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->TRUNCATEquery('be_users'));
+               $result = $this->subject->TRUNCATEquery('be_users');
                $expected = 'TRUNCATE TABLE "be_users"';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -177,9 +230,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/15535
         */
        public function distinctFieldIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('COUNT(DISTINCT pid)', 'tt_content', '1=1'));
+               $result = $this->subject->SELECTquery('COUNT(DISTINCT pid)', 'tt_content', '1=1');
                $expected = 'SELECT COUNT(DISTINCT "pid") FROM "tt_content" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -188,12 +241,12 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @remark Remapping is not expected here
         */
        public function multipleInnerJoinsAreProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local', '1=1'));
+               $result = $this->subject->SELECTquery('*', 'tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local', '1=1');
                $expected = 'SELECT * FROM "tt_news_cat"';
                $expected .= ' INNER JOIN "tt_news_cat_mm" ON "tt_news_cat"."uid"="tt_news_cat_mm"."uid_foreign"';
                $expected .= ' INNER JOIN "tt_news" ON "tt_news"."uid"="tt_news_cat_mm"."uid_local"';
                $expected .= ' WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -201,10 +254,10 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/17554
         */
        public function stringsWithinInClauseAreProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('COUNT(DISTINCT tx_dam.uid) AS count', 'tx_dam', 'tx_dam.pid IN (1) AND tx_dam.file_type IN (\'gif\',\'png\',\'jpg\',\'jpeg\') AND tx_dam.deleted = 0'));
+               $result = $this->subject->SELECTquery('COUNT(DISTINCT tx_dam.uid) AS count', 'tx_dam', 'tx_dam.pid IN (1) AND tx_dam.file_type IN (\'gif\',\'png\',\'jpg\',\'jpeg\') AND tx_dam.deleted = 0');
                $expected = 'SELECT COUNT(DISTINCT "tx_dam"."uid") AS "count" FROM "tx_dam"';
                $expected .= ' WHERE "tx_dam"."pid" IN (1) AND "tx_dam"."file_type" IN (\'gif\',\'png\',\'jpg\',\'jpeg\') AND "tx_dam"."deleted" = 0';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -213,10 +266,10 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @remark Remapping is not expected here
         */
        public function concatAfterLikeOperatorIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'sys_refindex, tx_dam_file_tracking', 'sys_refindex.tablename = \'tx_dam_file_tracking\'' . ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)'));
+               $result = $this->subject->SELECTquery('*', 'sys_refindex, tx_dam_file_tracking', 'sys_refindex.tablename = \'tx_dam_file_tracking\'' . ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)');
                $expected = 'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
                $expected .= ' AND (instr(LOWER("sys_refindex"."ref_string"), concat("tx_dam_file_tracking"."file_path","tx_dam_file_tracking"."file_name"),1,1) > 0)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -225,9 +278,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function cachingFrameworkQueryIsProperlyQuoted() {
                $currentTime = time();
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('content', 'cache_hash', 'identifier = ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('abbbabaf2d4b3f9a63e8dde781f1c106', 'cache_hash') . ' AND (crdate + lifetime >= ' . $currentTime . ' OR lifetime = 0)'));
+               $result = $this->subject->SELECTquery('content', 'cache_hash', 'identifier = ' . $this->subject->fullQuoteStr('abbbabaf2d4b3f9a63e8dde781f1c106', 'cache_hash') . ' AND (crdate + lifetime >= ' . $currentTime . ' OR lifetime = 0)');
                $expected = 'SELECT "content" FROM "cache_hash" WHERE "identifier" = \'abbbabaf2d4b3f9a63e8dde781f1c106\' AND ("crdate"+"lifetime" >= ' . $currentTime . ' OR "lifetime" = 0)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -236,18 +289,18 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function calculatedFieldsAreProperlyQuoted() {
                $currentTime = time();
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('identifier', 'cachingframework_cache_pages', 'crdate + lifetime < ' . $currentTime . ' AND lifetime > 0'));
+               $result = $this->subject->SELECTquery('identifier', 'cachingframework_cache_pages', 'crdate + lifetime < ' . $currentTime . ' AND lifetime > 0');
                $expected = 'SELECT "identifier" FROM "cachingframework_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime . ' AND "lifetime" > 0';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
         * @test
         */
        public function numericColumnsAreNotQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('1', 'be_users', 'username = \'_cli_scheduler\' AND admin = 0 AND be_users.deleted = 0'));
+               $result = $this->subject->SELECTquery('1', 'be_users', 'username = \'_cli_scheduler\' AND admin = 0 AND be_users.deleted = 0');
                $expected = 'SELECT 1 FROM "be_users" WHERE "username" = \'_cli_scheduler\' AND "admin" = 0 AND "be_users"."deleted" = 0';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -264,13 +317,14 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT * FROM "ext_tt_news_cat"';
                $expected .= ' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat"."cat_uid"="ext_tt_news_cat_mm"."uid_foreign"';
                $expected .= ' INNER JOIN "ext_tt_news" ON "ext_tt_news"."news_uid"="ext_tt_news_cat_mm"."local_uid"';
                $expected .= ' WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -283,10 +337,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "tstamp", "script", SUM("exec_time") AS "calc_sum", COUNT(*) AS "qrycount", MAX("errorflag") AS "error" FROM "tx_dbal_debuglog" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -299,12 +354,13 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'tt_news_cat_mm.uid_local > 50';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT MAX("ext_tt_news_cat"."cat_uid") AS "biggest_id" FROM "ext_tt_news_cat"';
                $expected .= ' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat"."cat_uid"="ext_tt_news_cat_mm"."uid_foreign"';
                $expected .= ' WHERE "ext_tt_news_cat_mm"."local_uid" > 50';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -318,11 +374,12 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'sys_refindex.tablename = \'tx_dam_file_tracking\'' . ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
                $expected .= ' AND (instr(LOWER("sys_refindex"."ref_string"), concat("tx_dam_file_tracking"."path","tx_dam_file_tracking"."filename"),1,1) > 0)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -335,11 +392,12 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'pages.uid = cpg_categories.pid AND pages.deleted = 0 AND 1 = 1';
                $groupBy = '';
                $orderBy = 'cpg_categories.pos';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "cpg_categories"."uid", "cpg_categories"."name" FROM "cpg_categories", "my_pages" WHERE "my_pages"."page_uid" = "cpg_categories"."page_id"';
                $expected .= ' AND "my_pages"."deleted" = 0 AND 1 = 1 ORDER BY "cpg_categories"."pos"';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -352,10 +410,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'news.uid = 1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "news"."news_uid" FROM "ext_tt_news" AS "news" WHERE "news"."news_uid" = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -371,33 +430,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'tt_news_cat.uid = 1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
-               $expected = 'SELECT "tt_news_cat"."news_uid" FROM "ext_tt_news" AS "tt_news_cat" WHERE "tt_news_cat"."news_uid" = 1';
-               $this->assertEquals($expected, $query);
-       }
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
 
-       /**
-        * @test
-        * @see http://forge.typo3.org/issues/22640
-        */
-       public function aliasRemappingDoesNotAlterFurtherQueries() {
-               $selectFields = 'foo.uid';
-               $fromTables = 'tt_news AS foo';
-               $whereClause = 'foo.uid = 1';
-               $groupBy = '';
-               $orderBy = '';
-               // First call to possibly alter (in memory) the mapping from localconf.php
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $selectFields = 'uid';
-               $fromTables = 'foo';
-               $whereClause = 'uid = 1';
-               $groupBy = '';
-               $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
-               $expected = 'SELECT "uid" FROM "foo" WHERE "uid" = 1';
-               $this->assertEquals($expected, $query);
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
+               $expected = 'SELECT "tt_news_cat"."news_uid" FROM "ext_tt_news" AS "tt_news_cat" WHERE "tt_news_cat"."news_uid" = 1';
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -410,14 +447,16 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "cat"."cat_uid", "cat_mm"."local_uid", "news"."news_uid"';
                $expected .= ' FROM "ext_tt_news_cat" AS "cat"';
                $expected .= ' INNER JOIN "ext_tt_news_cat_mm" AS "cat_mm" ON "cat"."cat_uid"="cat_mm"."uid_foreign"';
                $expected .= ' INNER JOIN "ext_tt_news" AS "news" ON "news"."news_uid"="cat_mm"."local_uid"';
                $expected .= ' WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -430,15 +469,15 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'tt_news_cat_mm.uid_foreign IN (SELECT foo.uid FROM tt_news_cat AS foo WHERE foo.hidden = 0)';
                $groupBy = '';
                $orderBy = 'foo.uid';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "foo"."news_uid" FROM "ext_tt_news" AS "foo"';
                $expected .= ' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat_mm"."local_uid"="foo"."news_uid"';
                $expected .= ' WHERE "ext_tt_news_cat_mm"."uid_foreign" IN (';
                $expected .= 'SELECT "foo"."cat_uid" FROM "ext_tt_news_cat" AS "foo" WHERE "foo"."hidden" = 0';
                $expected .= ')';
                $expected .= ' ORDER BY "foo"."news_uid"';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -451,15 +490,15 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'EXISTS (SELECT foo.uid FROM tt_news_cat AS foo WHERE foo.hidden = 0)';
                $groupBy = '';
                $orderBy = 'foo.uid';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "foo"."news_uid" FROM "ext_tt_news" AS "foo"';
                $expected .= ' INNER JOIN "ext_tt_news_cat_mm" ON "ext_tt_news_cat_mm"."local_uid"="foo"."news_uid"';
                $expected .= ' WHERE EXISTS (';
                $expected .= 'SELECT "foo"."cat_uid" FROM "ext_tt_news_cat" AS "foo" WHERE "foo"."hidden" = 0';
                $expected .= ')';
                $expected .= ' ORDER BY "foo"."news_uid"';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -472,15 +511,16 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'uid IN (' . 'SELECT foobar.uid_local FROM tt_news_cat_mm AS foobar WHERE uid_foreign IN (' . 'SELECT uid FROM tt_news_cat WHERE deleted = 0' . '))';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "foo"."news_uid" FROM "ext_tt_news" AS "foo"';
                $expected .= ' WHERE "news_uid" IN (';
                $expected .= 'SELECT "foobar"."local_uid" FROM "ext_tt_news_cat_mm" AS "foobar" WHERE "uid_foreign" IN (';
                $expected .= 'SELECT "cat_uid" FROM "ext_tt_news_cat" WHERE "deleted" = 0';
                $expected .= ')';
                $expected .= ')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -493,43 +533,60 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'pages.pid IN (SELECT uid FROM pages WHERE deleted = 0 AND cat_mm.uid_local != 100)';
                $groupBy = '';
                $orderBy = 'pages.uid';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "pages"."news_uid" FROM "ext_tt_news" AS "pages"';
                $expected .= ' INNER JOIN "ext_tt_news_cat_mm" AS "cat_mm" ON "cat_mm"."local_uid"="pages"."news_uid"';
                $expected .= ' WHERE "pages"."pid" IN (';
                $expected .= 'SELECT "page_uid" FROM "my_pages" WHERE "deleted" = 0 AND "cat_mm"."local_uid" != 100';
                $expected .= ')';
                $expected .= ' ORDER BY "pages"."news_uid"';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
         * @test
         * @see http://forge.typo3.org/issues/22716
         */
-       public function likeIsRemappedAccordingToFieldType() {
-               $GLOBALS['TYPO3_DB']->cache_fieldType['tt_content']['bodytext']['metaType'] = 'B';
-               $select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'tt_content.bodytext LIKE \'foo%\''));
+       public function likeIsRemappedAccordingToFieldTypeWithString() {
+               $this->subject->cache_fieldType['tt_content']['bodytext']['metaType'] = 'B';
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'tt_content.bodytext LIKE \'foo%\'');
                $expected = 'SELECT * FROM "tt_content" WHERE (dbms_lob.instr(LOWER("tt_content"."bodytext"), \'foo\',1,1) > 0)';
-               $this->assertEquals($expected, $select);
-               $select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'fe_users', 'fe_users.usergroup LIKE \'2\''));
+               $this->assertEquals($expected, $this->cleanSql($result));
+       }
+
+       /**
+        * @test
+        * @see http://forge.typo3.org/issues/22716
+        */
+       public function likeIsRemappedAccordingToFieldTypeWithInteger() {
+               $this->subject->cache_fieldType['tt_content']['bodytext']['metaType'] = 'B';
+               $result = $this->subject->SELECTquery('*', 'fe_users', 'fe_users.usergroup LIKE \'2\'');
                $expected = 'SELECT * FROM "fe_users" WHERE (instr(LOWER("fe_users"."usergroup"), \'2\',1,1) > 0)';
-               $this->assertEquals($expected, $select);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
         * @test
         * @see http://forge.typo3.org/issues/23282
         */
-       public function notLikeIsRemappedAccordingToFieldType() {
-               $GLOBALS['TYPO3_DB']->cache_fieldType['tt_content']['bodytext']['metaType'] = 'B';
-               $select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'tt_content.bodytext NOT LIKE \'foo%\''));
+       public function notLikeIsRemappedAccordingToFieldTypeWithString() {
+               $this->subject->cache_fieldType['tt_content']['bodytext']['metaType'] = 'B';
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'tt_content.bodytext NOT LIKE \'foo%\'');
                $expected = 'SELECT * FROM "tt_content" WHERE NOT (dbms_lob.instr(LOWER("tt_content"."bodytext"), \'foo\',1,1) > 0)';
-               $this->assertEquals($expected, $select);
-               $select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'fe_users', 'fe_users.usergroup NOT LIKE \'2\''));
+               $this->assertEquals($expected, $this->cleanSql($result));
+       }
+
+       /**
+        * @test
+        * @see http://forge.typo3.org/issues/23282
+        */
+       public function notLikeIsRemappedAccordingToFieldTypeWithInteger() {
+               $this->subject->cache_fieldType['tt_content']['bodytext']['metaType'] = 'B';
+               $result = $this->subject->SELECTquery('*', 'fe_users', 'fe_users.usergroup NOT LIKE \'2\'');
                $expected = 'SELECT * FROM "fe_users" WHERE NOT (instr(LOWER("fe_users"."usergroup"), \'2\',1,1) > 0)';
-               $this->assertEquals($expected, $select);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -537,7 +594,7 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/22716
         */
        public function instrIsUsedForCEOnPages() {
-               $select = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'uid IN (62) AND tt_content.deleted=0 AND tt_content.t3ver_state<=0' . ' AND tt_content.hidden=0 AND (tt_content.starttime<=1264487640)' . ' AND (tt_content.endtime=0 OR tt_content.endtime>1264487640)' . ' AND (tt_content.fe_group=\'\' OR tt_content.fe_group IS NULL OR tt_content.fe_group=\'0\'' . ' OR (tt_content.fe_group LIKE \'%,0,%\' OR tt_content.fe_group LIKE \'0,%\' OR tt_content.fe_group LIKE \'%,0\'' . ' OR tt_content.fe_group=\'0\')' . ' OR (tt_content.fe_group LIKE\'%,-1,%\' OR tt_content.fe_group LIKE \'-1,%\' OR tt_content.fe_group LIKE \'%,-1\'' . ' OR tt_content.fe_group=\'-1\'))'));
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'uid IN (62) AND tt_content.deleted=0 AND tt_content.t3ver_state<=0' . ' AND tt_content.hidden=0 AND (tt_content.starttime<=1264487640)' . ' AND (tt_content.endtime=0 OR tt_content.endtime>1264487640)' . ' AND (tt_content.fe_group=\'\' OR tt_content.fe_group IS NULL OR tt_content.fe_group=\'0\'' . ' OR (tt_content.fe_group LIKE \'%,0,%\' OR tt_content.fe_group LIKE \'0,%\' OR tt_content.fe_group LIKE \'%,0\'' . ' OR tt_content.fe_group=\'0\')' . ' OR (tt_content.fe_group LIKE\'%,-1,%\' OR tt_content.fe_group LIKE \'-1,%\' OR tt_content.fe_group LIKE \'%,-1\'' . ' OR tt_content.fe_group=\'-1\'))');
                $expected = 'SELECT * FROM "tt_content"';
                $expected .= ' WHERE "uid" IN (62) AND "tt_content"."deleted" = 0 AND "tt_content"."t3ver_state" <= 0';
                $expected .= ' AND "tt_content"."hidden" = 0 AND ("tt_content"."starttime" <= 1264487640)';
@@ -551,7 +608,7 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $expected .= ' OR (instr(LOWER("tt_content"."fe_group"), \'-1,\',1,1) > 0)';
                $expected .= ' OR (instr(LOWER("tt_content"."fe_group"), \',-1\',1,1) > 0)';
                $expected .= ' OR "tt_content"."fe_group" = \'-1\'))';
-               $this->assertEquals($expected, $select);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -580,9 +637,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                KEY bk_realurl02 (tablename,field_alias,field_id,value_alias(220),expire)
                        );
                ';
-               $components = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('parseCREATETABLE', $parseString);
+               $components = $this->subject->SQLparser->_callRef('parseCREATETABLE', $parseString);
                $this->assertTrue(is_array($components), 'Not an array: ' . $components);
-               $sqlCommands = $GLOBALS['TYPO3_DB']->SQLparser->_call('compileCREATETABLE', $components);
+               $sqlCommands = $this->subject->SQLparser->_call('compileCREATETABLE', $components);
                $this->assertTrue(is_array($sqlCommands), 'Not an array: ' . $sqlCommands);
                $this->assertEquals(4, count($sqlCommands));
                $expected = $this->cleanSql('
@@ -620,9 +677,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                KEY name (name)
                        );
                ';
-               $components = $GLOBALS['TYPO3_DB']->SQLparser->_callRef('parseCREATETABLE', $parseString);
+               $components = $this->subject->SQLparser->_callRef('parseCREATETABLE', $parseString);
                $this->assertTrue(is_array($components), 'Not an array: ' . $components);
-               $sqlCommands = $GLOBALS['TYPO3_DB']->SQLparser->_call('compileCREATETABLE', $components);
+               $sqlCommands = $this->subject->SQLparser->_call('compileCREATETABLE', $components);
                $this->assertTrue(is_array($sqlCommands), 'Not an array: ' . $sqlCommands);
                $this->assertEquals(2, count($sqlCommands));
                $expected = $this->cleanSql('
@@ -646,9 +703,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21688
         */
        public function inWhereClauseWithSubqueryIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_crawler_queue', 'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)'));
+               $result = $this->subject->SELECTquery('*', 'tx_crawler_queue', 'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)');
                $expected = 'SELECT * FROM "tx_crawler_queue" WHERE "process_id" IN (SELECT "process_id" FROM "tx_crawler_process" WHERE "active" = 0 AND "deleted" = 0)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -661,10 +718,10 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT * FROM "tx_crawler_queue" WHERE "process_id" IN (SELECT "ps_id" FROM "tx_crawler_ps" WHERE "is_active" = 0 AND "deleted" = 0)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -673,11 +730,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function cachingFrameworkQueryIsSupported() {
                $currentTime = time();
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->DELETEquery('cachingframework_cache_hash_tags', 'identifier IN (' . $GLOBALS['TYPO3_DB']->SELECTsubquery('identifier', 'cachingframework_cache_pages', ('crdate + lifetime < ' . $currentTime . ' AND lifetime > 0')) . ')'));
+               $result = $this->subject->DELETEquery('cachingframework_cache_hash_tags', 'identifier IN (' . $this->subject->SELECTsubquery('identifier', 'cachingframework_cache_pages', ('crdate + lifetime < ' . $currentTime . ' AND lifetime > 0')) . ')');
                $expected = 'DELETE FROM "cachingframework_cache_hash_tags" WHERE "identifier" IN (';
                $expected .= 'SELECT "identifier" FROM "cachingframework_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime . ' AND "lifetime" > 0';
                $expected .= ')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -687,23 +744,24 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function cachingFrameworkQueryIsRemapped() {
                $currentTime = time();
                $table = 'cachingframework_cache_hash_tags';
-               $where = 'identifier IN (' . $GLOBALS['TYPO3_DB']->SELECTsubquery('identifier', 'cachingframework_cache_pages', ('crdate + lifetime < ' . $currentTime . ' AND lifetime > 0')) . ')';
+               $where = 'identifier IN (' . $this->subject->SELECTsubquery('identifier', 'cachingframework_cache_pages', ('crdate + lifetime < ' . $currentTime . ' AND lifetime > 0')) . ')';
+
                // Perform remapping (as in method exec_DELETEquery)
-               if ($tableArray = $GLOBALS['TYPO3_DB']->_call('map_needMapping', $table)) {
-                       // Where clause:
-                       $whereParts = $GLOBALS['TYPO3_DB']->SQLparser->parseWhereClause($where);
-                       $GLOBALS['TYPO3_DB']->_callRef('map_sqlParts', $whereParts, $tableArray[0]['table']);
-                       $where = $GLOBALS['TYPO3_DB']->SQLparser->compileWhereClause($whereParts, FALSE);
-                       // Table name:
-                       if ($GLOBALS['TYPO3_DB']->mapping[$table]['mapTableName']) {
-                               $table = $GLOBALS['TYPO3_DB']->mapping[$table]['mapTableName'];
-                       }
+               $tableArray = $this->subject->_call('map_needMapping', $table);
+               // Where clause:
+               $whereParts = $this->subject->SQLparser->parseWhereClause($where);
+               $this->subject->_callRef('map_sqlParts', $whereParts, $tableArray[0]['table']);
+               $where = $this->subject->SQLparser->compileWhereClause($whereParts, FALSE);
+               // Table name:
+               if ($this->subject->mapping[$table]['mapTableName']) {
+                       $table = $this->subject->mapping[$table]['mapTableName'];
                }
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->DELETEquery($table, $where));
+
+               $result = $this->subject->DELETEquery($table, $where);
                $expected = 'DELETE FROM "cf_cache_hash_tags" WHERE "identifier" IN (';
                $expected .= 'SELECT "identifier" FROM "cf_cache_pages" WHERE "crdate"+"lifetime" < ' . $currentTime . ' AND "lifetime" > 0';
                $expected .= ')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -711,11 +769,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21688
         */
        public function existsWhereClauseIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tx_crawler_process', 'active = 0 AND NOT EXISTS (' . $GLOBALS['TYPO3_DB']->SELECTsubquery('*', 'tx_crawler_queue', 'tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)') . ')'));
+               $result = $this->subject->SELECTquery('*', 'tx_crawler_process', 'active = 0 AND NOT EXISTS (' . $this->subject->SELECTsubquery('*', 'tx_crawler_queue', 'tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)') . ')');
                $expected = 'SELECT * FROM "tx_crawler_process" WHERE "active" = 0 AND NOT EXISTS (';
                $expected .= 'SELECT * FROM "tx_crawler_queue" WHERE "tx_crawler_queue"."process_id" = "tx_crawler_process"."process_id" AND "tx_crawler_queue"."exec_time" = 0';
                $expected .= ')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -725,15 +783,16 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        public function subqueryIsRemappedForExistsWhereClause() {
                $selectFields = '*';
                $fromTables = 'tx_crawler_process';
-               $whereClause = 'active = 0 AND NOT EXISTS (' . $GLOBALS['TYPO3_DB']->SELECTsubquery('*', 'tx_crawler_queue', 'tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0') . ')';
+               $whereClause = 'active = 0 AND NOT EXISTS (' . $this->subject->SELECTsubquery('*', 'tx_crawler_queue', 'tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0') . ')';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT * FROM "tx_crawler_ps" WHERE "is_active" = 0 AND NOT EXISTS (';
                $expected .= 'SELECT * FROM "tx_crawler_queue" WHERE "tx_crawler_queue"."process_id" = "tx_crawler_ps"."ps_id" AND "tx_crawler_queue"."exec_time" = 0';
                $expected .= ')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -744,9 +803,10 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21903
         */
        public function caseStatementIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('process_id, CASE active' . ' WHEN 1 THEN ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('one', 'tx_crawler_process') . ' WHEN 2 THEN ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('two', 'tx_crawler_process') . ' ELSE ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('out of range', 'tx_crawler_process') . ' END AS number', 'tx_crawler_process', '1=1'));
+               $result = $this->subject->SELECTquery('process_id, CASE active' . ' WHEN 1 THEN ' . $this->subject->fullQuoteStr('one', 'tx_crawler_process') . ' WHEN 2 THEN ' . $this->subject->fullQuoteStr('two', 'tx_crawler_process') . ' ELSE ' . $this->subject->fullQuoteStr('out of range', 'tx_crawler_process') . ' END AS number', 'tx_crawler_process', '1=1');
                $expected = 'SELECT "process_id", CASE "active" WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS "number" FROM "tx_crawler_process" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -754,16 +814,17 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21903
         */
        public function caseStatementIsProperlyRemapped() {
-               $selectFields = 'process_id, CASE active' . ' WHEN 1 THEN ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('one', 'tx_crawler_process') . ' WHEN 2 THEN ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('two', 'tx_crawler_process') . ' ELSE ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('out of range', 'tx_crawler_process') . ' END AS number';
+               $selectFields = 'process_id, CASE active' . ' WHEN 1 THEN ' . $this->subject->fullQuoteStr('one', 'tx_crawler_process') . ' WHEN 2 THEN ' . $this->subject->fullQuoteStr('two', 'tx_crawler_process') . ' ELSE ' . $this->subject->fullQuoteStr('out of range', 'tx_crawler_process') . ' END AS number';
                $fromTables = 'tx_crawler_process';
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "ps_id", CASE "is_active" WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS "number" ';
                $expected .= 'FROM "tx_crawler_ps" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -771,16 +832,17 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21903
         */
        public function caseStatementWithExternalTableIsProperlyRemapped() {
-               $selectFields = 'process_id, CASE tt_news.uid' . ' WHEN 1 THEN ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('one', 'tt_news') . ' WHEN 2 THEN ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('two', 'tt_news') . ' ELSE ' . $GLOBALS['TYPO3_DB']->fullQuoteStr('out of range', 'tt_news') . ' END AS number';
+               $selectFields = 'process_id, CASE tt_news.uid' . ' WHEN 1 THEN ' . $this->subject->fullQuoteStr('one', 'tt_news') . ' WHEN 2 THEN ' . $this->subject->fullQuoteStr('two', 'tt_news') . ' ELSE ' . $this->subject->fullQuoteStr('out of range', 'tt_news') . ' END AS number';
                $fromTables = 'tx_crawler_process, tt_news';
                $whereClause = '1=1';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "ps_id", CASE "ext_tt_news"."news_uid" WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS "number" ';
                $expected .= 'FROM "tx_crawler_ps", "ext_tt_news" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -788,9 +850,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21902
         */
        public function locateStatementIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1'));
+               $result = $this->subject->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1');
                $expected = 'SELECT *, CASE WHEN INSTR("datastructure", \'(fce)\') > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -798,9 +860,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21902
         */
        public function locateStatementWithPositionIsProperlyQuoted() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $GLOBALS['TYPO3_DB']->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1'));
+               $result = $this->subject->SELECTquery('*, CASE WHEN' . ' LOCATE(' . $this->subject->fullQuoteStr('(fce)', 'tx_templavoila_tmplobj') . ', datastructure, 4)>0 THEN 2' . ' ELSE 1' . ' END AS scope', 'tx_templavoila_tmplobj', '1=1');
                $expected = 'SELECT *, CASE WHEN INSTR("datastructure", \'(fce)\', 4) > 0 THEN 2 ELSE 1 END AS "scope" FROM "tx_templavoila_tmplobj" WHERE 1 = 1';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -808,9 +870,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/17552
         */
        public function IfNullIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_news_cat_mm', 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)'));
+               $result = $this->subject->SELECTquery('*', 'tt_news_cat_mm', 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)');
                $expected = 'SELECT * FROM "tt_news_cat_mm" WHERE NVL("tt_news_cat_mm"."uid_foreign", 0) IN (21,22)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -818,9 +880,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/23087
         */
        public function findInSetIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)'));
+               $result = $this->subject->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)');
                $expected = 'SELECT * FROM "fe_users" WHERE \',\'||"usergroup"||\',\' LIKE \'%,10,%\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -833,10 +895,11 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $whereClause = 'FIND_IN_SET(10, fe_group)';
                $groupBy = '';
                $orderBy = '';
-               $remappedParameters = $GLOBALS['TYPO3_DB']->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->_call('SELECTqueryFromArray', $remappedParameters));
+               $remappedParameters = $this->subject->_call('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+
+               $result = $this->subject->_call('SELECTqueryFromArray', $remappedParameters);
                $expected = 'SELECT "usergroup" FROM "ext_tt_news" WHERE \',\'||"ext_tt_news"."usergroup"||\',\' LIKE \'%,10,%\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -844,9 +907,9 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/22959
         */
        public function listQueryIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'fe_users', $GLOBALS['TYPO3_DB']->listQuery('usergroup', 10, 'fe_users')));
+               $result = $this->subject->SELECTquery('*', 'fe_users', $this->subject->listQuery('usergroup', 10, 'fe_users'));
                $expected = 'SELECT * FROM "fe_users" WHERE \',\'||"usergroup"||\',\' LIKE \'%,10,%\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -854,9 +917,8 @@ class DatabaseConnectionOracleTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21514
         */
        public function likeBinaryOperatorIsRemoved() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\''));
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\'');
                $expected = 'SELECT * FROM "tt_content" WHERE (dbms_lob.instr("bodytext", \'test\',1,1) > 0)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
-
-}
+}
\ No newline at end of file
index c740803..558d934 100644 (file)
@@ -1,75 +1,79 @@
 <?php
 namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 
-/**
- * Test PostgreSQL database handling.
+/***************************************************************
+ * Copyright notice
  *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+ * (c) 2010-2014 Xavier Perseguers <xavier@typo3.org>
+ * 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.
+ * A copy is found in the text file GPL.txt and important notices to the license
+ * from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ * 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!
+ ***************************************************************/
 
-       /**
-        * Prepares the environment before running a test.
-        */
-       public function setUp() {
-               // Reconfigure DBAL to use PostgreSQL
-               require __DIR__ . '/Fixtures/postgresql.config.php';
-               $GLOBALS['TYPO3_DB'] = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('dummy'));
-               $GLOBALS['TYPO3_DB']->SQLparser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'));
-               $this->assertFalse($GLOBALS['TYPO3_DB']->isConnected());
-               // Initialize a fake PostgreSQL connection (using 'postgres7' as 'postgres' is remapped to it in AdoDB)
-               \TYPO3\CMS\Dbal\Tests\Unit\Database\FakeDatabaseConnection::connect($GLOBALS['TYPO3_DB'], 'postgres7');
-               $this->assertTrue($GLOBALS['TYPO3_DB']->isConnected());
-       }
+/**
+ * Test case
+ */
+class DatabaseConnectionPostgresqlTest extends AbstractTestCase {
 
        /**
-        * Cleans up the environment after running a test.
+        * @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
-       public function tearDown() {
-               // Clear DBAL-generated cache files
-               $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               parent::tearDown();
-       }
+       protected $subject;
 
        /**
-        * Cleans a SQL query.
+        * Prepare a DatabaseConnection subject ready to parse mssql queries
         *
-        * @param mixed $sql
-        * @return mixed (string or array)
+        * @return void
         */
-       private function cleanSql($sql) {
-               if (!is_string($sql)) {
-                       return $sql;
-               }
-               $sql = str_replace('
-', ' ', $sql);
-               $sql = preg_replace('/\\s+/', ' ', $sql);
-               return trim($sql);
-       }
-
-       /**
-        * @test
-        */
-       public function configurationIsUsingAdodbAndDriverPostgres() {
-               $configuration = $GLOBALS['TYPO3_DB']->conf['handlerCfg'];
-               $this->assertTrue(is_array($configuration) && count($configuration) > 0, 'No configuration found');
-               $this->assertEquals('adodb', $configuration['_DEFAULT']['type']);
-               $this->assertTrue($GLOBALS['TYPO3_DB']->runningADOdbDriver('postgres') !== FALSE, 'Not using postgres driver');
+       public function setUp() {
+               $configuration = array(
+                       'handlerCfg' => array(
+                               '_DEFAULT' => array(
+                                       'type' => 'adodb',
+                                       'config' => array(
+                                               'driver' => 'postgres',
+                                       ),
+                               ),
+                       ),
+                       'mapping' => array(
+                               'tx_templavoila_tmplobj' => array(
+                                       'mapFieldNames' => array(
+                                               'datastructure' => 'ds',
+                                       ),
+                               ),
+                               'Members' => array(
+                                       'mapFieldNames' => array(
+                                               'pid' => '0',
+                                               'cruser_id' => '1',
+                                               'uid' => 'MemberID',
+                                       ),
+                               ),
+                       ),
+               );
+               $this->subject = $this->prepareSubject('postgres7', $configuration);
        }
 
        /**
         * @test
         */
-       public function tablesWithMappingAreDetected() {
-               $tablesWithMapping = array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dbal']['mapping']);
-               foreach ($GLOBALS['TYPO3_DB']->cache_fieldType as $table => $fieldTypes) {
-                       $tableDef = $GLOBALS['TYPO3_DB']->_call('map_needMapping', $table);
-                       if (in_array($table, $tablesWithMapping)) {
-                               self::assertTrue(is_array($tableDef), 'Table ' . $table . ' was expected to need mapping');
-                       } else {
-                               self::assertFalse($tableDef, 'Table ' . $table . ' was not expected to need mapping');
-                       }
-               }
+       public function runningADOdbDriverReturnsTrueWithPostgresForPostgres8DefaultDriverConfiguration() {
+               $this->assertTrue($this->subject->runningADOdbDriver('postgres'));
        }
 
        /**
@@ -77,9 +81,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/15492
         */
        public function limitIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'be_users', '1=1', '', '', '20'));
+               $result = $this->subject->SELECTquery('*', 'be_users', '1=1', '', '', '20');
                $expected = 'SELECT * FROM "be_users" WHERE 1 = 1 LIMIT 20';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -87,9 +91,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/15492
         */
        public function limitWithSkipIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'be_users', '1=1', '', '', '20,40'));
+               $result = $this->subject->SELECTquery('*', 'be_users', '1=1', '', '', '20,40');
                $expected = 'SELECT * FROM "be_users" WHERE 1 = 1 LIMIT 40 OFFSET 20';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -97,9 +101,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/23087
         */
        public function findInSetIsProperlyRemapped() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)'));
+               $result = $this->subject->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)');
                $expected = 'SELECT * FROM "fe_users" WHERE FIND_IN_SET(10, "usergroup") != 0';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -107,9 +111,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/21514
         */
        public function likeBinaryOperatorIsRemappedToLike() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\''));
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\'');
                $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" LIKE \'test\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -117,9 +121,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/21514
         */
        public function notLikeBinaryOperatorIsRemappedToNotLike() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE BINARY \'test\''));
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE BINARY \'test\'');
                $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT LIKE \'test\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -127,9 +131,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/21514
         */
        public function likeOperatorIsRemappedToIlike() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext LIKE \'test\''));
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE \'test\'');
                $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" ILIKE \'test\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -137,9 +141,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/21514
         */
        public function notLikeOperatorIsRemappedToNotIlike() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE \'test\''));
+               $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE \'test\'');
                $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT ILIKE \'test\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -147,9 +151,9 @@ class DatabaseConnectionPostgresqlTest extends \TYPO3\CMS\Core\Tests\UnitTestCas
         * @see http://forge.typo3.org/issues/32626
         */
        public function notEqualAnsiOperatorCanBeParsed() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'pages', 'pid<>3'));
+               $result = $this->subject->SELECTquery('*', 'pages', 'pid<>3');
                $expected = 'SELECT * FROM "pages" WHERE "pid" <> 3';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
 }
index cb7f4f5..5e522d4 100644 (file)
@@ -1,36 +1,81 @@
 <?php
 namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 
-/**
- * Testcase for class DatabaseConnection.
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2010-2014 Xavier Perseguers <xavier@typo3.org>
+ * 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.
+ * A copy is found in the text file GPL.txt and important notices to the license
+ * from the author is found in LICENSE.txt distributed with these scripts.
  *
- * @author Xavier Perseguers <xavier@typo3.org>
+ * 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!
+ ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Test case
  */
-class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class DatabaseConnectionTest extends AbstractTestCase {
+
+       /**
+        * @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
+        */
+       protected $subject;
 
        /**
         * @var array
         */
-       protected $temporaryFiles;
+       protected $temporaryFiles = array();
 
        /**
-        * Prepares the environment before running a test.
+        * Set up
         */
        public function setUp() {
-               $this->temporaryFiles = array();
                $GLOBALS['TYPO3_LOADED_EXT'] = array();
-               $GLOBALS['TYPO3_DB'] = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('admin_get_charsets'));
-               $GLOBALS['TYPO3_DB']->expects($this->any())->method('admin_get_charsets')->will($this->returnValue(array('utf8' => array())));
-               $GLOBALS['TYPO3_DB']->initialize();
-               $GLOBALS['TYPO3_DB']->lastHandlerKey = '_DEFAULT';
+
+               /** @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('getFieldInfoCache'), array(), '', FALSE);
+
+               // Disable caching
+               $mockCacheFrontend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
+               $subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend));
+
+               // Inject SqlParser - Its logic is tested with the tests, too.
+               $sqlParser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'), array(), '', FALSE);
+               $sqlParser->_set('databaseConnection', $subject);
+               $subject->SQLparser = $sqlParser;
+
+               // Mock away schema migration service from install tool
+               $installerSqlMock = $this->getMock('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService', array('getFieldDefinitions_fileContent'), array(), '', FALSE);
+               $installerSqlMock->expects($this->any())->method('getFieldDefinitions_fileContent')->will($this->returnValue(array()));
+               $subject->_set('installerSql', $installerSqlMock);
+
+               $subject->initialize();
+               $subject->lastHandlerKey = '_DEFAULT';
+
+               $this->subject = $subject;
        }
 
        /**
-        * Cleans up the environment after running a test.
+        * Tear down.
         */
        public function tearDown() {
-               // Clear DBAL-generated cache files
-               $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
                // Delete temporary files
                foreach ($this->temporaryFiles as $filename) {
                        unlink($filename);
@@ -39,22 +84,6 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
-        * Cleans a SQL query.
-        *
-        * @param mixed $sql
-        * @return mixed (string or array)
-        */
-       private function cleanSql($sql) {
-               if (!is_string($sql)) {
-                       return $sql;
-               }
-               $sql = str_replace('
-', ' ', $sql);
-               $sql = preg_replace('/\\s+/', ' ', $sql);
-               return trim($sql);
-       }
-
-       /**
         * Creates a fake extension with a given table definition.
         *
         * @param string $tableDefinition SQL script to create the extension's tables
@@ -63,17 +92,54 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        protected function createFakeExtension($tableDefinition) {
                // Prepare a fake extension configuration
-               $ext_tables = \TYPO3\CMS\Core\Utility\GeneralUtility::tempnam('ext_tables');
-               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($ext_tables, $tableDefinition)) {
+               $ext_tables = GeneralUtility::tempnam('ext_tables');
+               if (!GeneralUtility::writeFile($ext_tables, $tableDefinition)) {
                        throw new \RuntimeException('Can\'t write temporary ext_tables file.');
                }
                $this->temporaryFiles[] = $ext_tables;
-               $GLOBALS['TYPO3_LOADED_EXT'] = array('test_dbal' => array(
-                       'ext_tables.sql' => $ext_tables
-               ));
+               $GLOBALS['TYPO3_LOADED_EXT'] = array(
+                       'test_dbal' => array(
+                               'ext_tables.sql' => $ext_tables
+                       )
+               );
                // Append our test table to the list of existing tables
-               $GLOBALS['TYPO3_DB']->clearCachedFieldInfo();
-               $GLOBALS['TYPO3_DB']->initialize();
+               $this->subject->initialize();
+       }
+
+       /**
+        * @test
+        */
+       public function tableWithMappingIsDetected() {
+               $dbalConfiguration = array(
+                       'mapping' => array(
+                               'cf_cache_hash' => array(),
+                       ),
+               );
+
+               /** @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array('getFieldInfoCache'), array(), '', FALSE);
+
+               $mockCacheFrontend = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
+               $subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend));
+
+               $sqlParser = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'), array(), '', FALSE);
+               $sqlParser->_set('databaseConnection', $subject);
+               $subject->SQLparser = $sqlParser;
+
+               $installerSqlMock = $this->getMock('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService', array(), array(), '', FALSE);
+               $subject->_set('installerSql', $installerSqlMock);
+               $schemaMigrationResult = array(
+                       'cf_cache_pages' => array(),
+               );
+               $installerSqlMock->expects($this->once())->method('getFieldDefinitions_fileContent')->will($this->returnValue($schemaMigrationResult));
+
+               $subject->conf = $dbalConfiguration;
+               $subject->initialize();
+               $subject->lastHandlerKey = '_DEFAULT';
+
+               $this->assertFalse($subject->_call('map_needMapping', 'cf_cache_pages'));
+               $cfCacheHashNeedsMapping = $subject->_call('map_needMapping', 'cf_cache_hash');
+               $this->assertEquals('cf_cache_hash', $cfCacheHashNeedsMapping[0]['table']);
        }
 
        /**
@@ -81,10 +147,10 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21502
         */
        public function concatCanBeParsedAfterLikeOperator() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'sys_refindex, tx_dam_file_tracking', 'sys_refindex.tablename = \'tx_dam_file_tracking\'' . ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)'));
+               $result = $this->subject->SELECTquery('*', 'sys_refindex, tx_dam_file_tracking', 'sys_refindex.tablename = \'tx_dam_file_tracking\'' . ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)');
                $expected = 'SELECT * FROM sys_refindex, tx_dam_file_tracking WHERE sys_refindex.tablename = \'tx_dam_file_tracking\'';
                $expected .= ' AND sys_refindex.ref_string LIKE CONCAT(tx_dam_file_tracking.file_path, tx_dam_file_tracking.file_name)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -102,9 +168,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        'foo' => 99.12,
                        'foobar' => -120
                );
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->INSERTquery('tx_test_dbal', $data));
+               $result = $this->subject->INSERTquery('tx_test_dbal', $data);
                $expected = 'INSERT INTO tx_test_dbal ( foo, foobar ) VALUES ( \'99.12\', \'-120\' )';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -122,30 +188,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        'foo' => 9223372036854775807,
                        'foobar' => 9223372036854775807
                );
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->INSERTquery('tx_test_dbal', $data));
+               $result = $this->subject->INSERTquery('tx_test_dbal', $data);
                $expected = 'INSERT INTO tx_test_dbal ( foo, foobar ) VALUES ( \'9223372036854775807\', \'9223372036854775807\' )';
-               $this->assertEquals($expected, $query);
-       }
-
-       /**
-        * @test
-        * @see http://forge.typo3.org/issues/20427
-        */
-       public function negative64BitIntegerIsSupported() {
-               $this->markTestSkipped('This test causes problems on some systems.');
-               $this->createFakeExtension('
-                       CREATE TABLE tx_test_dbal (
-                               foo int default \'0\',
-                               foobar bigint default \'0\'
-                       );
-               ');
-               $data = array(
-                       'foo' => -9.2233720368548E+18,
-                       'foobar' => -9.2233720368548E+18
-               );
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->INSERTquery('tx_test_dbal', $data));
-               $expected = 'INSERT INTO tx_test_dbal ( foo, foobar ) VALUES ( \'-9223372036854775808\', \'-9223372036854775808\' )';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -158,12 +203,12 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        array('3', '4', 'Title #2', 'Content #2'),
                        array('5', '6', 'Title #3', 'Content #3')
                );
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->INSERTmultipleRows('tt_content', $fields, $rows));
+               $result = $this->subject->INSERTmultipleRows('tt_content', $fields, $rows);
                $expected = 'INSERT INTO tt_content (uid, pid, title, body) VALUES ';
                $expected .= '(\'1\', \'2\', \'Title #1\', \'Content #1\'), ';
                $expected .= '(\'3\', \'4\', \'Title #2\', \'Content #2\'), ';
                $expected .= '(\'5\', \'6\', \'Title #3\', \'Content #3\')';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -171,9 +216,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/16708
         */
        public function minFunctionAndInOperatorCanBeParsed() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'pages', 'MIN(uid) IN (1,2,3,4)'));
+               $result = $this->subject->SELECTquery('*', 'pages', 'MIN(uid) IN (1,2,3,4)');
                $expected = 'SELECT * FROM pages WHERE MIN(uid) IN (1,2,3,4)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -181,9 +226,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/16708
         */
        public function maxFunctionAndInOperatorCanBeParsed() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'pages', 'MAX(uid) IN (1,2,3,4)'));
+               $result = $this->subject->SELECTquery('*', 'pages', 'MAX(uid) IN (1,2,3,4)');
                $expected = 'SELECT * FROM pages WHERE MAX(uid) IN (1,2,3,4)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -191,9 +236,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21514
         */
        public function likeBinaryOperatorIsKept() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\''));
+               $result = $this->cleanSql($this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\''));
                $expected = 'SELECT * FROM tt_content WHERE bodytext LIKE BINARY \'test\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -201,9 +246,9 @@ class DatabaseConnectionTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @see http://forge.typo3.org/issues/21514
         */
        public function notLikeBinaryOperatorIsKept() {
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE BINARY \'test\''));
+               $result = $this->cleanSql($this->subject->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE BINARY \'test\''));
                $expected = 'SELECT * FROM tt_content WHERE bodytext NOT LIKE BINARY \'test\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
diff --git a/typo3/sysext/dbal/Tests/Unit/Database/FakeDatabaseConnection.php b/typo3/sysext/dbal/Tests/Unit/Database/FakeDatabaseConnection.php
deleted file mode 100644 (file)
index 28a3ceb..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
-
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2009-2013 Xavier Perseguers <xavier@typo3.org>
- *  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!
- ***************************************************************/
-/**
- * Fake ADOdb connection factory.
- *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-class FakeDatabaseConnection {
-
-       /**
-        * Creates a fake database connection.
-        *
-        * @param \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $db
-        * @param string $driver Driver to use (e.g., 'oci8')
-        * @return \ADOConnection
-        */
-       static public function connect(\TYPO3\CMS\Dbal\Database\DatabaseConnection $db, $driver) {
-               $GLOBALS['TYPO3_LOADED_EXT'] = array();
-               // Make sure to have a clean configuration
-               $db->clearCachedFieldInfo();
-               $db->initialize();
-               require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('adodb') . 'adodb/adodb.inc.php';
-               require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('adodb') . 'adodb/drivers/adodb-' . $driver . '.inc.php';
-               $handlerKey = '_DEFAULT';
-               $db->lastHandlerKey = $handlerKey;
-               $db->handlerInstance[$handlerKey] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('ADODB_' . $driver);
-               // From method handler_init()
-               $db->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($db->handlerInstance[$handlerKey]);
-               // DataDictionary being set, a connectionID may be arbitrarily chosen
-               $db->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
-       }
-
-}
diff --git a/typo3/sysext/dbal/Tests/Unit/Database/Fixtures/mssql.config.php b/typo3/sysext/dbal/Tests/Unit/Database/Fixtures/mssql.config.php
deleted file mode 100644 (file)
index ec1fb72..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * MS SQL configuration
- *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-global $TYPO3_CONF_VARS;
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['handlerCfg'] = array(
-       '_DEFAULT' => array(
-               'type' => 'adodb',
-               'config' => array(
-                       'driver' => 'mssql',
-                       'useNameQuote' => FALSE,
-                       'quoteClob' => FALSE
-               )
-       )
-);
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] = array(
-       'tx_templavoila_tmplobj' => array(
-               'mapFieldNames' => array(
-                       'datastructure' => 'ds'
-               )
-       ),
-       'Members' => array(
-               'mapFieldNames' => array(
-                       'pid' => '0',
-                       'cruser_id' => '1',
-                       'uid' => 'MemberID'
-               )
-       )
-);
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['table2handlerKeys'] = array();
diff --git a/typo3/sysext/dbal/Tests/Unit/Database/Fixtures/oci8.config.php b/typo3/sysext/dbal/Tests/Unit/Database/Fixtures/oci8.config.php
deleted file mode 100644 (file)
index 088a8d7..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/**
- * Oracle configuration
- *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-global $TYPO3_CONF_VARS;
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['handlerCfg'] = array(
-       '_DEFAULT' => array(
-               'type' => 'adodb',
-               'config' => array(
-                       'driver' => 'oci8'
-               )
-       )
-);
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] = array(
-       'cachingframework_cache_hash' => array(
-               'mapTableName' => 'cf_cache_hash'
-       ),
-       'cachingframework_cache_hash_tags' => array(
-               'mapTableName' => 'cf_cache_hash_tags'
-       ),
-       'cachingframework_cache_pages' => array(
-               'mapTableName' => 'cf_cache_pages'
-       ),
-       'cpg_categories' => array(
-               'mapFieldNames' => array(
-                       'pid' => 'page_id'
-               )
-       ),
-       'pages' => array(
-               'mapTableName' => 'my_pages',
-               'mapFieldNames' => array(
-                       'uid' => 'page_uid'
-               )
-       ),
-       'tt_news' => array(
-               'mapTableName' => 'ext_tt_news',
-               'mapFieldNames' => array(
-                       'uid' => 'news_uid',
-                       'fe_group' => 'usergroup'
-               )
-       ),
-       'tt_news_cat' => array(
-               'mapTableName' => 'ext_tt_news_cat',
-               'mapFieldNames' => array(
-                       'uid' => 'cat_uid'
-               )
-       ),
-       'tt_news_cat_mm' => array(
-               'mapTableName' => 'ext_tt_news_cat_mm',
-               'mapFieldNames' => array(
-                       'uid_local' => 'local_uid'
-               )
-       ),
-       'tx_crawler_process' => array(
-               'mapTableName' => 'tx_crawler_ps',
-               'mapFieldNames' => array(
-                       'process_id' => 'ps_id',
-                       'active' => 'is_active'
-               )
-       ),
-       'tx_dam_file_tracking' => array(
-               'mapFieldNames' => array(
-                       'file_name' => 'filename',
-                       'file_path' => 'path'
-               )
-       ),
-       'tx_dbal_debuglog' => array(
-               'mapFieldNames' => array(
-                       'errorFlag' => 'errorflag'
-               )
-       ),
-       'tx_templavoila_datastructure' => array(
-               'mapTableName' => 'tx_templavoila_ds'
-       )
-);
diff --git a/typo3/sysext/dbal/Tests/Unit/Database/Fixtures/postgresql.config.php b/typo3/sysext/dbal/Tests/Unit/Database/Fixtures/postgresql.config.php
deleted file mode 100644 (file)
index 95ccef9..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-/**
- * PostgreSQL configuration
- *
- * @author Xavier Perseguers <xavier@typo3.org>
- */
-global $TYPO3_CONF_VARS;
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['handlerCfg'] = array(
-       '_DEFAULT' => array(
-               'type' => 'adodb',
-               'config' => array(
-                       'driver' => 'postgres'
-               )
-       )
-);
-$TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] = array(
-       'tx_templavoila_tmplobj' => array(
-               'mapFieldNames' => array(
-                       'datastructure' => 'ds'
-               )
-       ),
-       'Members' => array(
-               'mapFieldNames' => array(
-                       'pid' => '0',
-                       'cruser_id' => '1',
-                       'uid' => 'MemberID'
-               )
-       )
-);
index 092389f..1106c81 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2009-2013 Xavier Perseguers <xavier@typo3.org>
+ *  (c) 2009-2014 Xavier Perseguers <xavier@typo3.org>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -26,55 +26,39 @@ namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
 
 /**
  * Test case
- *
- * @author Xavier Perseguers <xavier@typo3.org>
  */
-class SqlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+class SqlParserTest extends AbstractTestCase {
 
        /**
-        * @var \TYPO3\CMS\Dbal\Database\SqlParser
+        * @var \TYPO3\CMS\Dbal\Database\SqlParser|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
         */
-       protected $fixture;
+       protected $subject;
 
        /**
         * Prepares the environment before running a test.
         */
        public function setUp() {
-               $GLOBALS['TYPO3_DB'] = new \TYPO3\CMS\Dbal\Database\DatabaseConnection();
-               $this->fixture = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'));
-               $GLOBALS['TYPO3_DB']->lastHandlerKey = '_DEFAULT';
-               $GLOBALS['TYPO3_DB']->SQLparser = $this->fixture;
-       }
+               $subject = $this->getAccessibleMock('TYPO3\\CMS\\Dbal\\Database\\SqlParser', array('dummy'), array(), '', FALSE);
 
-       /**
-        * Cleans a SQL query.
-        *
-        * @param mixed $sql
-        * @return mixed (string or array)
-        */
-       private function cleanSql($sql) {
-               if (!is_string($sql)) {
-                       return $sql;
-               }
-               $sql = str_replace('
-', ' ', $sql);
-               $sql = preg_replace('/\\s+/', ' ', $sql);
-               return trim($sql);
+               $mockDatabaseConnection = $this->getMock('TYPO3\\CMS\\Dbal\\Database\\DatabaseConnection', array(), array(), '', FALSE);
+               $mockDatabaseConnection->lastHandlerKey = '_DEFAULT';
+               $subject->_set('databaseConnection', $mockDatabaseConnection);
+
+               $this->subject = $subject;
        }
 
        /**
         * @test
         */
        public function canExtractPartsOfAQuery() {
-               $parseString = 'SELECT   *
-FROM pages WHERE pid IN (1,2,3,4)';
+               $parseString = 'SELECT   *' . LF . 'FROM pages WHERE pid IN (1,2,3,4)';
                $regex = '^SELECT[[:space:]]+(.*)[[:space:]]+';
                $trimAll = TRUE;
-               $fields = $this->fixture->_callRef('nextPart', $parseString, $regex, $trimAll);
+               $fields = $this->subject->_callRef('nextPart', $parseString, $regex, $trimAll);
                $this->assertEquals('*', $fields);
                $this->assertEquals('FROM pages WHERE pid IN (1,2,3,4)', $parseString);
                $regex = '^FROM ([^)]+) WHERE';
-               $table = $this->fixture->_callRef('nextPart', $parseString, $regex);
+               $table = $this->subject->_callRef('nextPart', $parseString, $regex);
                $this->assertEquals('pages', $table);
                $this->assertEquals('pages WHERE pid IN (1,2,3,4)', $parseString);
        }
@@ -84,9 +68,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canGetIntegerValue() {
                $parseString = '1024';
-               $value = $this->fixture->_callRef('getValue', $parseString);
+               $result = $this->subject->_callRef('getValue', $parseString);
                $expected = array(1024);
-               $this->assertEquals($expected, $value);
+               $this->assertEquals($expected, $result);
        }
 
        /**
@@ -95,9 +79,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canGetStringValue() {
                $parseString = '"some owner\\\'s string"';
-               $value = $this->fixture->_callRef('getValue', $parseString);
+               $result = $this->subject->_callRef('getValue', $parseString);
                $expected = array('some owner\'s string', '"');
-               $this->assertEquals($expected, $value);
+               $this->assertEquals($expected, $result);
        }
 
        /**
@@ -106,9 +90,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canGetStringValueWithSingleQuote() {
                $parseString = '\'some owner\\\'s string\'';
-               $value = $this->fixture->_callRef('getValue', $parseString);
+               $result = $this->subject->_callRef('getValue', $parseString);
                $expected = array('some owner\'s string', '\'');
-               $this->assertEquals($expected, $value);
+               $this->assertEquals($expected, $result);
        }
 
        /**
@@ -117,9 +101,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canGetStringValueWithDoubleQuote() {
                $parseString = '"the \\"owner\\" is here"';
-               $value = $this->fixture->_callRef('getValue', $parseString);
+               $result = $this->subject->_callRef('getValue', $parseString);
                $expected = array('the "owner" is here', '"');
-               $this->assertEquals($expected, $value);
+               $this->assertEquals($expected, $result);
        }
 
        /**
@@ -128,14 +112,14 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function canGetListOfValues() {
                $parseString = '( 1,   2, 3  ,4)';
                $operator = 'IN';
-               $values = $this->fixture->_callRef('getValue', $parseString, $operator);
+               $result = $this->subject->_callRef('getValue', $parseString, $operator);
                $expected = array(
                        array(1),
                        array(2),
                        array(3),
                        array(4)
                );
-               $this->assertEquals($expected, $values);
+               $this->assertEquals($expected, $result);
        }
 
        /**
@@ -143,9 +127,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parseWhereClauseReturnsArray() {
                $parseString = 'uid IN (1,2) AND (starttime < ' . time() . ' OR cruser_id + 10 < 20)';
-               $where = $this->fixture->parseWhereClause($parseString);
-               $this->assertTrue(is_array($where), $where);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseWhereClause($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -154,8 +138,8 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function canSelectAllFieldsFromPages() {
                $sql = 'SELECT * FROM pages';
                $expected = $sql;
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $result = $this->subject->debug_testSQL($sql);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -164,8 +148,8 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function canParseTruncateTable() {
                $sql = 'TRUNCATE TABLE be_users';
                $expected = $sql;
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $result = $this->subject->debug_testSQL($sql);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -174,12 +158,13 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseAndCompileBetweenOperator() {
                $parseString = '((scheduled BETWEEN 1265068628 AND 1265068828 ) OR scheduled <= 1265068728) AND NOT exec_time AND NOT process_id AND page_id=1 AND parameters_hash = \'854e9a2a77\'';
-               $where = $this->fixture->parseWhereClause($parseString);
-               $this->assertTrue(is_array($where), $where);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
-               $whereClause = $this->cleanSql($this->fixture->compileWhereClause($where));
+               $result = $this->subject->parseWhereClause($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
+
+               $result = $this->subject->compileWhereClause($result);
                $expected = '((scheduled BETWEEN 1265068628 AND 1265068828) OR scheduled <= 1265068728) AND NOT exec_time AND NOT process_id AND page_id = 1 AND parameters_hash = \'854e9a2a77\'';
-               $this->assertEquals($expected, $whereClause);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -187,11 +172,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseInsertWithoutSpaceAfterValues() {
                $parseString = 'INSERT INTO static_country_zones VALUES(\'483\', \'0\', \'NL\', \'NLD\', \'528\', \'DR\', \'Drenthe\', \'\');';
-               $components = $this->fixture->_callRef('parseINSERT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $components = $this->subject->_callRef('parseINSERT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileINSERT', $components);
                $expected = 'INSERT INTO static_country_zones VALUES (\'483\', \'0\', \'NL\', \'NLD\', \'528\', \'DR\', \'Drenthe\', \'\')';
-               $this->assertEquals($expected, $insert);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -199,11 +185,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseInsertWithSpaceAfterValues() {
                $parseString = 'INSERT INTO static_country_zones VALUES (\'483\', \'0\', \'NL\', \'NLD\', \'528\', \'DR\', \'Drenthe\', \'\');';
-               $components = $this->fixture->_callRef('parseINSERT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $components = $this->subject->_callRef('parseINSERT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileINSERT', $components);
                $expected = 'INSERT INTO static_country_zones VALUES (\'483\', \'0\', \'NL\', \'NLD\', \'528\', \'DR\', \'Drenthe\', \'\')';
-               $this->assertEquals($expected, $insert);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -212,12 +199,13 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function canParseInsertWithFields() {
                $parseString = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
                $parseString .= 'VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\');';
-               $components = $this->fixture->_callRef('parseINSERT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $components = $this->subject->_callRef('parseINSERT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileINSERT', $components);
                $expected = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
                $expected .= 'VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\')';
-               $this->assertEquals($expected, $insert);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -225,11 +213,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseExtendedInsert() {
                $parseString = 'INSERT INTO static_territories VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\'),(\'2\', \'0\', \'9\', \'0\', \'Oceania\'),' . '(\'3\', \'0\', \'19\', \'0\', \'Americas\'),(\'4\', \'0\', \'142\', \'0\', \'Asia\');';
-               $components = $this->fixture->_callRef('parseINSERT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $components = $this->subject->_callRef('parseINSERT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileINSERT', $components);
                $expected = 'INSERT INTO static_territories VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\'), (\'2\', \'0\', \'9\', \'0\', \'Oceania\'), ' . '(\'3\', \'0\', \'19\', \'0\', \'Americas\'), (\'4\', \'0\', \'142\', \'0\', \'Asia\')';
-               $this->assertEquals($expected, $insert);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -238,12 +227,13 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function canParseExtendedInsertWithFields() {
                $parseString = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
                $parseString .= 'VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\'),(\'2\', \'0\', \'9\', \'0\', \'Oceania\');';
-               $components = $this->fixture->_callRef('parseINSERT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $insert = $this->cleanSql($this->fixture->_callRef('compileINSERT', $components));
+               $components = $this->subject->_callRef('parseINSERT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileINSERT', $components);
                $expected = 'INSERT INTO static_territories (uid, pid, tr_iso_nr, tr_parent_iso_nr, tr_name_en) ';
                $expected .= 'VALUES (\'1\', \'0\', \'2\', \'0\', \'Africa\'), (\'2\', \'0\', \'9\', \'0\', \'Oceania\')';
-               $this->assertEquals($expected, $insert);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -252,9 +242,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseIfNullOperator() {
                $parseString = 'IFNULL(tt_news_cat_mm.uid_foreign,0) IN (21,22)';
-               $whereParts = $this->fixture->parseWhereClause($parseString);
-               $this->assertTrue(is_array($whereParts), $whereParts);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseWhereClause($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -269,9 +259,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
                $parseString .= 'OR (tt_news.fe_group LIKE \'%,0,%\' OR tt_news.fe_group LIKE \'0,%\' OR tt_news.fe_group LIKE \'%,0\' ';
                $parseString .= 'OR tt_news.fe_group=\'0\') OR (tt_news.fe_group LIKE \'%,-1,%\' OR tt_news.fe_group LIKE \'-1,%\' ';
                $parseString .= 'OR tt_news.fe_group LIKE \'%,-1\' OR tt_news.fe_group=\'-1\'))';
-               $whereParts = $this->fixture->parseWhereClause($parseString);
-               $this->assertTrue(is_array($whereParts), $whereParts);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+
+               $result = $this->subject->parseWhereClause($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -280,11 +271,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canCompileIfNullOperator() {
                $parseString = 'SELECT * FROM tx_irfaq_q_cat_mm WHERE IFNULL(tx_irfaq_q_cat_mm.uid_foreign,0) = 1';
-               $components = $this->fixture->_callRef('parseSELECT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $select = $this->cleanSql($this->fixture->_callRef('compileSELECT', $components));
+               $components = $this->subject->_callRef('parseSELECT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileSELECT', $components);
                $expected = 'SELECT * FROM tx_irfaq_q_cat_mm WHERE IFNULL(tx_irfaq_q_cat_mm.uid_foreign, 0) = 1';
-               $this->assertEquals($expected, $select);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -293,11 +285,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseAlterEngineStatement() {
                $parseString = 'ALTER TABLE tx_realurl_pathcache ENGINE=InnoDB';
-               $components = $this->fixture->_callRef('parseALTERTABLE', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $alterTable = $this->cleanSql($this->fixture->_callRef('compileALTERTABLE', $components));
+               $components = $this->subject->_callRef('parseALTERTABLE', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileALTERTABLE', $components);
                $expected = 'ALTER TABLE tx_realurl_pathcache ENGINE = InnoDB';
-               $this->assertEquals($expected, $alterTable);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -306,11 +299,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseAlterCharacterSetStatement() {
                $parseString = 'ALTER TABLE `index_phash` DEFAULT CHARACTER SET utf8';
-               $components = $this->fixture->_callRef('parseALTERTABLE', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $alterTable = $this->cleanSql($this->fixture->_callRef('compileALTERTABLE', $components));
+               $components = $this->subject->_callRef('parseALTERTABLE', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileALTERTABLE', $components);
                $expected = 'ALTER TABLE index_phash DEFAULT CHARACTER SET utf8';
-               $this->assertEquals($expected, $alterTable);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -319,11 +313,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseFindInSetStatement() {
                $parseString = 'SELECT * FROM fe_users WHERE FIND_IN_SET(10, usergroup)';
-               $components = $this->fixture->_callRef('parseSELECT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $selectTable = $this->cleanSql($this->fixture->_callRef('compileSELECT', $components));
+               $components = $this->subject->_callRef('parseSELECT', $parseString);
+               $this->assertInternalType('array', $components);
+
+               $result = $this->subject->_callRef('compileSELECT', $components);
                $expected = 'SELECT * FROM fe_users WHERE FIND_IN_SET(10, usergroup)';
-               $this->assertEquals($expected, $selectTable);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -332,9 +327,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseSingleQuote() {
                $parseString = 'SELECT * FROM pages WHERE title=\'1\\\'\' AND deleted=0';
-               $components = $this->fixture->_callRef('parseSELECT', $parseString);
-               $this->assertTrue(is_array($components), $components);
-               $this->assertTrue(empty($components['parseString']), 'parseString is not empty');
+               $result = $this->subject->_callRef('parseSELECT', $parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($result['parseString']);
        }
 
        ///////////////////////////////////////
@@ -345,9 +340,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parseFromTablesWithInnerJoinReturnsArray() {
                $parseString = 'be_users INNER JOIN pages ON pages.cruser_id = be_users.uid';
-               $tables = $this->fixture->parseFromTables($parseString);
-               $this->assertTrue(is_array($tables), $tables);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+
+               $result = $this->subject->parseFromTables($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -355,9 +351,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parseFromTablesWithLeftOuterJoinReturnsArray() {
                $parseString = 'be_users LEFT OUTER JOIN pages ON be_users.uid = pages.cruser_id';
-               $tables = $this->fixture->parseFromTables($parseString);
-               $this->assertTrue(is_array($tables), $tables);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+
+               $result = $this->subject->parseFromTables($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -366,9 +363,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parseFromTablesWithRightOuterJoinReturnsArray() {
                $parseString = 'tx_powermail_fieldsets RIGHT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid';
-               $tables = $this->fixture->parseFromTables($parseString);
-               $this->assertTrue(is_array($tables), $tables);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+
+               $result = $this->subject->parseFromTables($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -376,9 +374,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parseFromTablesWithMultipleJoinsReturnsArray() {
                $parseString = 'be_users LEFT OUTER JOIN pages ON be_users.uid = pages.cruser_id INNER JOIN cache_pages cp ON cp.page_id = pages.uid';
-               $tables = $this->fixture->parseFromTables($parseString);
-               $this->assertTrue(is_array($tables), $tables);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseFromTables($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -387,9 +385,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parseFromTablesWithMultipleJoinsAndParenthesesReturnsArray() {
                $parseString = 'tx_powermail_fieldsets RIGHT JOIN tt_content ON tx_powermail_fieldsets.tt_content = tt_content.uid LEFT JOIN tx_powermail_fields ON tx_powermail_fieldsets.uid = tx_powermail_fields.fieldset';
-               $tables = $this->fixture->parseFromTables($parseString);
-               $this->assertTrue(is_array($tables), $tables);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseFromTables($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -397,9 +395,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canUseInnerJoinInSelect() {
                $sql = 'SELECT pages.uid, be_users.username FROM be_users INNER JOIN pages ON pages.cruser_id = be_users.uid';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT pages.uid, be_users.username FROM be_users INNER JOIN pages ON pages.cruser_id=be_users.uid';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -407,9 +406,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canUseMultipleInnerJoinsInSelect() {
                $sql = 'SELECT * FROM tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid = tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid = tt_news_cat_mm.uid_local';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM tt_news_cat INNER JOIN tt_news_cat_mm ON tt_news_cat.uid=tt_news_cat_mm.uid_foreign INNER JOIN tt_news ON tt_news.uid=tt_news_cat_mm.uid_local';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -418,9 +418,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseMultipleJoinConditions() {
                $sql = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.pid = T1.uid AND T2.size = 4 WHERE T1.cr_userid = 1';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.pid=T1.uid AND T2.size=4 WHERE T1.cr_userid = 1';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -429,9 +430,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function canParseMultipleJoinConditionsWithLessThanOperator() {
                $sql = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.size < 4 OR T2.pid = T1.uid WHERE T1.cr_userid = 1';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM T1 LEFT OUTER JOIN T2 ON T2.size<4 OR T2.pid=T1.uid WHERE T1.cr_userid = 1';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -460,30 +462,8 @@ FROM pages WHERE pid IN (1,2,3,4)';
                                KEY bk_realurl02 (tablename,field_alias,field_id,value_alias(220),expire)
                        );
                ';
-               $createTables = $this->fixture->_callRef('parseCREATETABLE', $parseString);
-               $this->assertTrue(is_array($createTables), $createTables);
-       }
-
-       /**
-        * @test
-        * @see http://forge.typo3.org/issues/24156
-        */
-       public function indexMayBeCreatedOnMultipleColumns() {
-               $sql = '
-                       CREATE TABLE sys_registry (
-                               uid int(11) unsigned NOT NULL auto_increment,
-                               entry_namespace varchar(128) DEFAULT \'\' NOT NULL,
-                               entry_key varchar(128) DEFAULT \'\' NOT NULL,
-                               entry_value blob,
-                               PRIMARY KEY (uid),
-                               UNIQUE KEY entry_identifier (entry_namespace,entry_key)
-                       )
-               ';
-               $parseString = $sql;
-               $createTables = $this->fixture->_callRef('parseCREATETABLE', $parseString);
-               $this->assertTrue(is_array($createTables), $createTables);
-               $actual = $this->fixture->_callRef('compileCREATETABLE', $createTables);
-               $this->assertEquals($this->cleanSql($sql), $this->cleanSql($actual[0]));
+               $result = $this->subject->_callRef('parseCREATETABLE', $parseString);
+               $this->assertInternalType('array', $result);
        }
 
        /**
@@ -492,8 +472,8 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function indexMayContainALengthRestrictionInAlterTable() {
                $parseString = 'ALTER TABLE tx_realurl_uniqalias ADD KEY bk_realurl02 (tablename,field_alias,field_id,value_alias(220),expire)';
-               $alterTables = $this->fixture->_callRef('parseALTERTABLE', $parseString);
-               $this->assertTrue(is_array($alterTables), $alterTables);
+               $result = $this->subject->_callRef('parseALTERTABLE', $parseString);
+               $this->assertInternalType('array', $result);
        }
 
        /**
@@ -503,8 +483,8 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function canParseUniqueIndexCreation() {
                $sql = 'ALTER TABLE static_territories ADD UNIQUE uid (uid)';
                $expected = $sql;
-               $alterTables = $this->fixture->_callRef('parseALTERTABLE', $sql);
-               $queries = $this->fixture->compileSQL($alterTables);
+               $alterTables = $this->subject->_callRef('parseALTERTABLE', $sql);
+               $queries = $this->subject->compileSQL($alterTables);
                $this->assertEquals($expected, $queries);
        }
 
@@ -517,9 +497,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function inWhereClauseSupportsSubquery() {
                $parseString = 'process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)';
-               $whereParts = $this->fixture->parseWhereClause($parseString);
-               $this->assertTrue(is_array($whereParts), $whereParts);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseWhereClause($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -528,9 +508,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function inWhereClauseWithSubqueryIsProperlyCompiled() {
                $sql = 'SELECT * FROM tx_crawler_queue WHERE process_id IN (SELECT process_id FROM tx_crawler_process WHERE active=0 AND deleted=0)';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM tx_crawler_queue WHERE process_id IN (SELECT process_id FROM tx_crawler_process WHERE active = 0 AND deleted = 0)';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -539,9 +520,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function whereClauseSupportsExistsKeyword() {
                $parseString = 'EXISTS (SELECT * FROM tx_crawler_queue WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)';
-               $whereParts = $this->fixture->parseWhereClause($parseString);
-               $this->assertTrue(is_array($whereParts), $whereParts);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseWhereClause($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -550,9 +531,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function existsClauseIsProperlyCompiled() {
                $sql = 'SELECT * FROM tx_crawler_process WHERE active = 0 AND NOT EXISTS (SELECT * FROM tx_crawler_queue WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM tx_crawler_process WHERE active = 0 AND NOT EXISTS (SELECT * FROM tx_crawler_queue WHERE tx_crawler_queue.process_id = tx_crawler_process.process_id AND tx_crawler_queue.exec_time = 0)';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -564,9 +546,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function caseWithBooleanConditionIsSupportedInFields() {
                $parseString = 'CASE WHEN 1>0 THEN 2 ELSE 1 END AS foo, other_column';
-               $fieldList = $this->fixture->parseFieldList($parseString);
-               $this->assertTrue(is_array($fieldList), $fieldList);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseFieldList($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -575,9 +557,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function caseWithBooleanConditionIsProperlyCompiled() {
                $sql = 'SELECT CASE WHEN 1>0 THEN 2 ELSE 1 END AS foo, other_column FROM mytable';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT CASE WHEN 1 > 0 THEN 2 ELSE 1 END AS foo, other_column FROM mytable';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -586,9 +569,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function caseWithMultipleWhenIsSupportedInFields() {
                $parseString = 'CASE column WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS number';
-               $fieldList = $this->fixture->parseFieldList($parseString);
-               $this->assertTrue(is_array($fieldList), $fieldList);
-               $this->assertTrue(empty($parseString), 'parseString is not empty');
+               $result = $this->subject->parseFieldList($parseString);
+               $this->assertInternalType('array', $result);
+               $this->assertEmpty($parseString);
        }
 
        /**
@@ -597,9 +580,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function caseWithMultipleWhenIsProperlyCompiled() {
                $sql = 'SELECT CASE column WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS number FROM mytable';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT CASE column WHEN 1 THEN \'one\' WHEN 2 THEN \'two\' ELSE \'out of range\' END AS number FROM mytable';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -608,9 +592,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function locateIsSupported() {
                $sql = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\', datastructure)>0';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\', datastructure) > 0';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -620,8 +605,8 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function locateWithPositionIsSupported() {
                $sql = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\'  , datastructure  ,10)>0';
                $expected = 'SELECT * FROM tx_templavoila_tmplobj WHERE LOCATE(\'(fce)\', datastructure, 10) > 0';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $result = $this->cleanSql($this->subject->debug_testSQL($sql));
+               $this->assertEquals($expected, $result);
        }
 
        /**
@@ -631,9 +616,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function locateWithinCaseIsSupported() {
                $sql = 'SELECT *, CASE WHEN LOCATE(\'(fce)\', datastructure)>0 THEN 2 ELSE 1 END AS scope FROM tx_templavoila_tmplobj';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT *, CASE WHEN LOCATE(\'(fce)\', datastructure) > 0 THEN 2 ELSE 1 END AS scope FROM tx_templavoila_tmplobj';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        ///////////////////////////////////////
@@ -645,9 +631,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function namedPlaceholderIsSupported() {
                $sql = 'SELECT * FROM pages WHERE pid = :pid ORDER BY title';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM pages WHERE pid = :pid ORDER BY title';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -656,9 +643,10 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function questionMarkPlaceholderIsSupported() {
                $sql = 'SELECT * FROM pages WHERE pid = ? ORDER BY title';
+
+               $result = $this->subject->debug_testSQL($sql);
                $expected = 'SELECT * FROM pages WHERE pid = ? ORDER BY title';
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql));
-               $this->assertEquals($expected, $actual);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -667,10 +655,9 @@ FROM pages WHERE pid IN (1,2,3,4)';
         */
        public function parametersAreReferenced() {
                $sql = 'SELECT * FROM pages WHERE pid = :pid1 OR pid = :pid2';
-               $components = $this->fixture->_callRef('parseSELECT', $sql);
-               $this->assertTrue(is_array($components['parameters']), 'References to parameters not found');
+               $components = $this->subject->_callRef('parseSELECT', $sql);
+               $this->assertInternalType('array', $components['parameters']);
                $this->assertEquals(2, count($components['parameters']));
-               $this->assertTrue(is_array($components['parameters']), 'References to parameters not found');
                $this->assertTrue(isset($components['parameters'][':pid1']));
                $this->assertTrue(isset($components['parameters'][':pid2']));
        }
@@ -682,11 +669,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function sameParameterIsReferencedInSubquery() {
                $sql = 'SELECT * FROM pages WHERE uid = :pageId OR uid IN (SELECT uid FROM pages WHERE pid = :pageId)';
                $pageId = 12;
-               $components = $this->fixture->_callRef('parseSELECT', $sql);
+               $components = $this->subject->_callRef('parseSELECT', $sql);
                $components['parameters'][':pageId'][0] = $pageId;
-               $query = $this->cleanSql($this->fixture->_callRef('compileSELECT', $components));
+
+               $result = $this->subject->_callRef('compileSELECT', $components);
                $expected = 'SELECT * FROM pages WHERE uid = 12 OR uid IN (SELECT uid FROM pages WHERE pid = 12)';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -696,11 +684,12 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function namedParametersMayBeSafelyReplaced() {
                $sql = 'SELECT * FROM pages WHERE pid = :pid AND title NOT LIKE \':pid\'';
                $pid = 12;
-               $components = $this->fixture->_callRef('parseSELECT', $sql);
+               $components = $this->subject->_callRef('parseSELECT', $sql);
                $components['parameters'][':pid'][0] = $pid;
-               $query = $this->cleanSql($this->fixture->_callRef('compileSELECT', $components));
+
+               $result = $this->subject->_callRef('compileSELECT', $components);
                $expected = 'SELECT * FROM pages WHERE pid = ' . $pid . ' AND title NOT LIKE \':pid\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
 
        /**
@@ -710,13 +699,13 @@ FROM pages WHERE pid IN (1,2,3,4)';
        public function questionMarkParametersMayBeSafelyReplaced() {
                $sql = 'SELECT * FROM pages WHERE pid = ? AND timestamp < ? AND title != \'How to test?\'';
                $parameterValues = array(12, 1281782690);
-               $components = $this->fixture->_callRef('parseSELECT', $sql);
+               $components = $this->subject->_callRef('parseSELECT', $sql);
                for ($i = 0; $i < count($components['parameters']['?']); $i++) {
                        $components['parameters']['?'][$i][0] = $parameterValues[$i];
                }
-               $query = $this->cleanSql($this->fixture->_callRef('compileSELECT', $components));
+
+               $result = $this->subject->_callRef('compileSELECT', $components);
                $expected = 'SELECT * FROM pages WHERE pid = 12 AND timestamp < 1281782690 AND title != \'How to test?\'';
-               $this->assertEquals($expected, $query);
+               $this->assertEquals($expected, $this->cleanSql($result));
        }
-
-}
+}
\ No newline at end of file