[limb-svn] r6836 - in 3.x/trunk/limb/dbal/tests/cases/non-driver: . query

svn at limb-project.com svn at limb-project.com
Fri Mar 14 18:46:50 MSK 2008


Author: svk
Date: 2008-03-14 18:46:50 +0300 (Fri, 14 Mar 2008)
New Revision: 6836
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6836

Modified:
   3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php
   3.x/trunk/limb/dbal/tests/cases/non-driver/lmbTableGatewayTest.class.php
   3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbInsertQueryTest.class.php
   3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbUpdateQueryTest.class.php
Log:
-- dbal tests changed:
-- -- all identifiers quoted
-- -- direct insert / update for autoinc fields deprecated


Modified: 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php	2008-03-14 13:22:27 UTC (rev 6835)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbSimpleDbTest.class.php	2008-03-14 15:46:50 UTC (rev 6836)
@@ -56,7 +56,7 @@
   //we test sequence based fields here
   function testInsertPrimaryKeyValue()
   {
-    $id = $this->db->insert('test_db_table', array('id' => 20,
+    $id = $this->db->insert('test_db_table', array(/*'id' => 20,*/
                                                    'title' =>  'wow',
                                                    'description' => 'wow!'));
 
@@ -65,7 +65,7 @@
 
     $this->assertEqual($record->get('title'), 'wow');
     $this->assertEqual($record->get('description'), 'wow!');
-    $this->assertEqual("$id", '20');
+    //$this->assertEqual("$id", '20');
     $this->assertEqual($record->get('id'), $id);
   }
 
@@ -102,7 +102,7 @@
                       new lmbSQLFieldCriteria('title', 'wow'));
     $this->assertEqual($this->db->countAffected(), 2);
 
-    $stmt = $this->conn->newStatement("SELECT * FROM test_db_table ORDER BY id");
+    $stmt = $this->conn->newStatement("SELECT * FROM test_db_table ORDER BY " . $this->conn->quoteIdentifier('id'));
     $records = $stmt->getRecordSet();
 
     $records->rewind();
@@ -165,7 +165,7 @@
     $this->db->insert('test_db_table', $data[1]);
 
     $this->assertEqual($this->db->countAffected(), 0);
-    $this->db->delete('test_db_table',new lmbSQLFieldCriteria('description', 'description'));
+    $this->db->delete('test_db_table',new lmbSQLFieldCriteria('title', 'wow'));
     $this->assertEqual($this->db->countAffected(), 1);
 
     $stmt = $this->conn->newStatement("SELECT * FROM test_db_table");

Modified: 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbTableGatewayTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbTableGatewayTest.class.php	2008-03-14 13:22:27 UTC (rev 6835)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/lmbTableGatewayTest.class.php	2008-03-14 15:46:50 UTC (rev 6836)
@@ -63,11 +63,11 @@
     $this->assertEqual($record->get('id'), $id);
   }
 
-  function testInsertUpdatesSequenceIfAutoIncrementFieldWasSet()
-  {
-    $id = $this->db_table_test->insert(array('id' => 4, 'title' =>  'wow', 'description' => 'wow!'));
-    $this->assertEqual($id, 4);
-  }
+//  function testInsertUpdatesSequenceIfAutoIncrementFieldWasSet()
+//  {
+//    $id = $this->db_table_test->insert(array('id' => 4, 'title' =>  'wow', 'description' => 'wow!'));
+//    $this->assertEqual($id, 4);
+//  }
 
   function testInsertThrowsExceptionIfAllFieldsWereFiltered()
   {
@@ -106,7 +106,7 @@
     $this->db_table_test->insert(array('ordr' =>  '1'));
     $this->db_table_test->insert(array('ordr' =>  '10'));
 
-    $this->db_table_test->update('ordr=ordr+1');
+    $this->db_table_test->update($this->conn->quoteIdentifier('ordr') . '=' . $this->conn->quoteIdentifier('ordr') . '+1');
 
     $this->assertEqual($this->db_table_test->getAffectedRowCount(), 2);
 
@@ -136,7 +136,7 @@
 
     $this->assertEqual($this->db_table_test->getAffectedRowCount(), 2);
 
-    $stmt = $this->conn->newStatement("SELECT * FROM test_db_table ORDER BY id");
+    $stmt = $this->conn->newStatement("SELECT * FROM test_db_table ORDER BY " . $this->conn->quoteIdentifier('id'));
     $records = $stmt->getRecordSet();
 
     $records->rewind();
@@ -159,7 +159,7 @@
 
     $this->assertEqual($this->db_table_test->getAffectedRowCount(), 1);
 
-    $stmt = $this->conn->newStatement("SELECT * FROM test_db_table WHERE id=$id");
+    $stmt = $this->conn->newStatement('SELECT * FROM test_db_table WHERE ' . $this->conn->quoteIdentifier('id') . '=' . $id);
     $records = $stmt->getRecordSet();
     $records->rewind();
     $record = $records->current();
@@ -254,7 +254,7 @@
 
   function testSelectFirstRecordReturnNullIfNothingIsFound()
   {
-    $this->assertNull($this->db_table_test->selectFirstRecord('id = -10000'));
+    $this->assertNull($this->db_table_test->selectFirstRecord($this->conn->quoteIdentifier('id') . '= -10000'));
   }
 
   function testDeleteAll()

Modified: 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbInsertQueryTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbInsertQueryTest.class.php	2008-03-14 13:22:27 UTC (rev 6835)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbInsertQueryTest.class.php	2008-03-14 15:46:50 UTC (rev 6836)
@@ -35,10 +35,10 @@
 
   function testInsert()
   {
-    $this->db->insert('test_db_table', array('id' => 100));
+    $startId = $this->db->insert('test_db_table', array('description' => 'text1'));
 
     $query = new lmbInsertQuery('test_db_table', $this->conn);
-    $query->addField('id', $id = 101);
+    $query->addField('id', $id = $startId+1);
     $query->addField('description', $description = 'Some \'description\'');
     $query->addField('title', $title = 'Some title');
 
@@ -49,7 +49,7 @@
     $arr = $rs->getArray();
 
     $this->assertEqual(sizeof($arr), 2);
-    $this->assertEqual($arr[0]['id'], 100);
+    $this->assertEqual($arr[0]['id'], $startId);
     $this->assertEqual($arr[1]['id'], $id);
     $this->assertEqual($arr[1]['description'], $description);
     $this->assertEqual($arr[1]['title'], $title);
@@ -58,12 +58,12 @@
   function testAddFieldWithoutValueOnlyReservesAPlaceholder()
   {
     $query = new lmbInsertQuery('test_db_table', $this->conn);
-    $query->addField('id');
+    //$query->addField('id');
     $query->addField('description');
     $query->addField('title');
 
     $stmt = $query->getStatement();
-    $stmt->set('id', $id = 101);
+    //$stmt->set('id', $id = 101);
     $stmt->set('description', $description = 'Some \'description\'');
     $stmt->set('title', $title = 'Some title');
     $stmt->execute();
@@ -72,7 +72,7 @@
     $arr = $rs->getArray();
 
     $this->assertEqual(sizeof($arr), 1);
-    $this->assertEqual($arr[0]['id'], $id);
+    //$this->assertEqual($arr[0]['id'], $id);
     $this->assertEqual($arr[0]['description'], $description);
     $this->assertEqual($arr[0]['title'], $title);
 

Modified: 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbUpdateQueryTest.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbUpdateQueryTest.class.php	2008-03-14 13:22:27 UTC (rev 6835)
+++ 3.x/trunk/limb/dbal/tests/cases/non-driver/query/lmbUpdateQueryTest.class.php	2008-03-14 15:46:50 UTC (rev 6836)
@@ -36,8 +36,8 @@
 
   function testUpdate()
   {
-    $this->db->insert('test_db_table', array('id' => 100));
-    $this->db->insert('test_db_table', array('id' => 101));
+    $startId = $this->db->insert('test_db_table', array('description' => 'text1'));
+    $this->db->insert('test_db_table', array('description' => 'text2'));
 
     $query = new lmbUpdateQuery('test_db_table', $this->conn);
     $query->addField('description', $description = 'Some description');
@@ -51,7 +51,7 @@
     $record = $rs->current();
     $this->assertEqual($record->get('title'), $title);
     $this->assertEqual($record->get('description'), $description);
-
+    
     $rs->next();
     $record = $rs->current();
     $this->assertEqual($record->get('title'), $title);
@@ -60,7 +60,7 @@
 
   function testUpdateAddFieldWithoutValueOnlyReservesAPlaceholder()
   {
-    $this->db->insert('test_db_table', array('id' => 101));
+    $startId = $this->db->insert('test_db_table', array('description' => 'text1'));
 
     $query = new lmbUpdateQuery('test_db_table', $this->conn);
     $query->addField('description');
@@ -78,31 +78,31 @@
     $this->assertEqual($record->get('description'), $description);
   }
 
-  function testUpdateSpecialCase()
-  {
-    $this->db->insert('test_db_table', array('id' => 100));
+//  function testUpdateSpecialCase()
+//  {
+//    $startId = $this->db->insert('test_db_table', array('description' => 'text1'));
+//
+//    $query = new lmbUpdateQuery('test_db_table', $this->conn);
+//    $query->addRawField($this->conn->quoteIdentifier('id') . ' = ' . $this->conn->quoteIdentifier('id') . ' + 1');
+//
+//    $stmt = $query->getStatement($this->conn);
+//    $stmt->execute();
+//
+//    $rs = $this->db->select('test_db_table');
+//    $rs->rewind();
+//    $record = $rs->current();
+//    $this->assertEqual($record->get('id'), $startId + 1);
+//  }
 
-    $query = new lmbUpdateQuery('test_db_table', $this->conn);
-    $query->addRawField('id = id + 1');
-
-    $stmt = $query->getStatement($this->conn);
-    $stmt->execute();
-
-    $rs = $this->db->select('test_db_table');
-    $rs->rewind();
-    $record = $rs->current();
-    $this->assertEqual($record->get('id'), 101);
-  }
-
   function testUpdateWithCriteria()
   {
-    $this->db->insert('test_db_table', array('id' => 100));
-    $this->db->insert('test_db_table', array('id' => 101));
+    $startId = $this->db->insert('test_db_table', array('description' => ''));
+    $this->db->insert('test_db_table', array('description' => ''));
 
     $query = new lmbUpdateQuery('test_db_table', $this->conn);
     $query->addField('description', $description = 'Some description');
     $query->addField('title', $title = 'Some title');
-    $query->addCriteria(new lmbSQLFieldCriteria('id', 101));
+    $query->addCriteria(new lmbSQLFieldCriteria('id', $startId+1));
 
     $stmt = $query->getStatement($this->conn);
     $stmt->execute();
@@ -110,21 +110,21 @@
     $rs = $this->db->select('test_db_table');
     $rs->rewind();
     $record = $rs->current(); //this one is not changed
-    $this->assertEqual($record->get('id'), 100);
+    $this->assertEqual($record->get('id'), $startId);
     $this->assertEqual($record->get('title'), '');
     $this->assertEqual($record->get('description'), '');
 
     $rs->next();
     $record = $rs->current();
-    $this->assertEqual($record->get('id'), 101);
+    $this->assertEqual($record->get('id'), $startId+1);
     $this->assertEqual($record->get('title'), $title);
     $this->assertEqual($record->get('description'), $description);
   }
 
   function testChaining()
   {
-    $this->db->insert('test_db_table', array('id' => 100));
-    $this->db->insert('test_db_table', array('id' => 101));
+    $startId = $this->db->insert('test_db_table', array('description' => ''));
+    $this->db->insert('test_db_table', array('description' => ''));
 
     $description = 'Some description';
     $title = 'Some title';
@@ -132,20 +132,20 @@
     $query = new lmbUpdateQuery('test_db_table', $this->conn);
     $query->set(array('description' => $description))->
             field('title', $title)->
-            rawField('id = id + 10')->
-            where('id=101')->
+            //rawField($this->conn->quoteIdentifier('id') . ' = ' . $this->conn->quoteIdentifier('id') . ' + 10')->
+            where($this->conn->quoteIdentifier('id') . '=' . intval($startId + 1))->
             execute();
 
     $rs = $this->db->select('test_db_table');
     $rs->rewind();
     $record = $rs->current(); //this one is not changed
-    $this->assertEqual($record->get('id'), 100);
+    $this->assertEqual($record->get('id'), $startId);
     $this->assertEqual($record->get('title'), '');
     $this->assertEqual($record->get('description'), '');
 
     $rs->next();
     $record = $rs->current();
-    $this->assertEqual($record->get('id'), 111);
+    //$this->assertEqual($record->get('id'), $startId + 11);
     $this->assertEqual($record->get('title'), $title);
     $this->assertEqual($record->get('description'), $description);
   }



More information about the limb-svn mailing list