Reorganized unit-tests
authorXavier Perseguers <typo3@perseguers.ch>
Fri, 27 Nov 2009 11:02:36 +0000 (11:02 +0000)
committerXavier Perseguers <typo3@perseguers.ch>
Fri, 27 Nov 2009 11:02:36 +0000 (11:02 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/dbal/trunk@27050 735d13b6-9817-0410-8766-e36946ffe9aa

typo3/sysext/dbal/ChangeLog
typo3/sysext/dbal/tests/db_oracle_testcase.php
typo3/sysext/dbal/tests/sqlparser_general_testcase.php

index 894d749..e63f638 100644 (file)
@@ -1,3 +1,7 @@
+2009-11-27  Xavier Perseguers  <typo3@perseguers.ch>
+
+       * Reorganized unit-tests
+
 2009-11-25  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Set version to 1.0.1
index fad80b4..1fa2cdc 100644 (file)
@@ -125,6 +125,10 @@ class db_oracle_testcase extends BaseTestCase {
                }
        }
 
+       ///////////////////////////////////////
+       // Tests concerning quoting
+       ///////////////////////////////////////
+
        /**
         * @test
         */
@@ -172,6 +176,42 @@ class db_oracle_testcase extends BaseTestCase {
                $this->assertEquals($expected, $query);
        }
 
+       /** 
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=6198
+        */
+       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'
+               ));
+               $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);
+       }
+
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=12515
+        * @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)'
+               ));
+               $expected = 'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
+               $expected .= ' AND (dbms_lob.instr("sys_refindex"."ref_string", CONCAT("tx_dam_file_tracking"."file_path","tx_dam_file_tracking"."file_name"),1,1) > 0)';
+               $this->assertEquals($expected, $query);
+       }
+
+       ///////////////////////////////////////
+       // Tests concerning remapping
+       ///////////////////////////////////////
+
        /**
         * @test
         * @see http://bugs.typo3.org/view.php?id=10411
@@ -194,21 +234,6 @@ class db_oracle_testcase extends BaseTestCase {
                $this->assertEquals($expected, $query);
        }
 
-       /** 
-        * @test
-        * @see http://bugs.typo3.org/view.php?id=6198
-        */
-       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'
-               ));
-               $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);
-       }
-
        /**
         * @test
         * @see http://bugs.typo3.org/view.php?id=6953
@@ -247,23 +272,6 @@ class db_oracle_testcase extends BaseTestCase {
                $this->assertEquals($expected, $query);
        }
 
-       /**
-        * @test
-        * @see http://bugs.typo3.org/view.php?id=12515
-        * @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)'
-               ));
-               $expected = 'SELECT * FROM "sys_refindex", "tx_dam_file_tracking" WHERE "sys_refindex"."tablename" = \'tx_dam_file_tracking\'';
-               $expected .= ' AND (dbms_lob.instr("sys_refindex"."ref_string", CONCAT("tx_dam_file_tracking"."file_path","tx_dam_file_tracking"."file_name"),1,1) > 0)';
-               $this->assertEquals($expected, $query);
-       }
-
        /**
         * @test
         * @see http://bugs.typo3.org/view.php?id=12515
@@ -285,6 +293,29 @@ class db_oracle_testcase extends BaseTestCase {
                $this->assertEquals($expected, $query);
        }
 
+       /**
+        * @test
+        * @see http://bugs.typo3.org/view.php?id=5708
+        */
+       public function fieldIsMappedOnRightSideOfAJoinCondition() {
+               $selectFields = 'cpg_categories.uid, cpg_categories.name';
+               $fromTables   = 'cpg_categories, pages';
+               $whereClause  = 'pages.uid = cpg_categories.pid AND pages.deleted = 0 AND 1 = 1';
+               $groupBy      = '';
+               $orderBy      = 'cpg_categories.pos';
+
+               $GLOBALS['TYPO3_DB']->_callRef('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
+               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery($selectFields, $fromTables, $whereClause, $groupBy, $orderBy));
+
+               $expected = 'SELECT "cpg_categories"."uid", "cpg_categories"."name" FROM "cpg_categories", "pages" WHERE "pages"."uid" = "cpg_categories"."page_id"';
+               $expected .= ' AND "pages"."deleted" = 0 AND 1 = 1 ORDER BY "cpg_categories"."pos"';
+               $this->assertEquals($expected, $query);
+       }
+
+       ///////////////////////////////////////
+       // Tests concerning DB management
+       ///////////////////////////////////////
+
        /**
         * @test
         * @see http://bugs.typo3.org/view.php?id=12670
@@ -370,25 +401,6 @@ class db_oracle_testcase extends BaseTestCase {
                        )
                ');
                $this->assertEquals($expected, $this->cleanSql($sqlCommands[0]));
-       }
-
-       /**
-        * @test
-        * @see http://bugs.typo3.org/view.php?id=5708
-        */
-       public function fieldIsMappedOnRightSideOfAJoinCondition() {
-               $selectFields = 'cpg_categories.uid, cpg_categories.name';
-               $fromTables   = 'cpg_categories, pages';
-               $whereClause  = 'pages.uid = cpg_categories.pid AND pages.deleted = 0 AND 1 = 1';
-               $groupBy      = '';
-               $orderBy      = 'cpg_categories.pos';
-
-               $GLOBALS['TYPO3_DB']->_callRef('map_remapSELECTQueryParts', $selectFields, $fromTables, $whereClause, $groupBy, $orderBy);
-               $query = $this->cleanSql($GLOBALS['TYPO3_DB']->SELECTquery($selectFields, $fromTables, $whereClause, $groupBy, $orderBy));
-
-               $expected = 'SELECT "cpg_categories"."uid", "cpg_categories"."name" FROM "cpg_categories", "pages" WHERE "pages"."uid" = "cpg_categories"."page_id"';
-               $expected .= ' AND "pages"."deleted" = 0 AND 1 = 1 ORDER BY "cpg_categories"."pos"';
-               $this->assertEquals($expected, $query);
-       }
+       }       
 }
 ?>
\ No newline at end of file
index 7c9fadc..6976a04 100644 (file)
@@ -143,6 +143,32 @@ class sqlparser_general_testcase extends BaseTestCase {
                $this->assertEquals($expected, $values);
        }
 
+       /**
+        * @test
+        */
+       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');
+       }
+
+       /**
+        * @test
+        */
+       public function canSelectAllFieldsFromPages() {
+               $sql = 'SELECT * FROM pages';
+               $expected = $sql;
+               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
+
+               $this->assertEquals($expected, $actual);
+       }
+
+       ///////////////////////////////////////
+       // Tests concerning JOINs
+       ///////////////////////////////////////
+
        /**
         * @test
         */
@@ -200,28 +226,6 @@ class sqlparser_general_testcase extends BaseTestCase {
                $this->assertTrue(empty($parseString), 'parseString is not empty');
        }
 
-       /**
-        * @test
-        */
-       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');
-       }
-
-       /**
-        * @test
-        */
-       public function canSelectAllFieldsFromPages() {
-               $sql = 'SELECT * FROM pages';
-               $expected = $sql;
-               $actual = $this->cleanSql($this->fixture->debug_testSQL($sql)); 
-
-               $this->assertEquals($expected, $actual);
-       }
-
        /**
         * @test
         */
@@ -244,6 +248,10 @@ class sqlparser_general_testcase extends BaseTestCase {
                $this->assertEquals($expected, $actual);
        }
 
+       ///////////////////////////////////////
+       // Tests concerning DB management
+       ///////////////////////////////////////
+
        /** 
         * @test
         * @see http://bugs.typo3.org/view.php?id=4466