Author: dr
Date: Tue Jan  8 13:34:53 2008
New Revision: 7102

Log:
- Added test case for issue #10777.

Added:
    trunk/Database/tests/sqlabstraction/files/
    trunk/Database/tests/sqlabstraction/files/bug10777.dba
Modified:
    trunk/Database/tests/sqlabstraction/query_update_test.php

Added: trunk/Database/tests/sqlabstraction/files/bug10777.dba
==============================================================================
--- trunk/Database/tests/sqlabstraction/files/bug10777.dba (added)
+++ trunk/Database/tests/sqlabstraction/files/bug10777.dba [iso-8859-1] Tue Jan 
 8 13:34:53 2008
@@ -1,0 +1,26 @@
+<?php return array (
+  0 => 
+  array (
+    'bug10777' => 
+    ezcDbSchemaTable::__set_state(array(
+       'fields' => 
+      array (
+        'bar' => 
+        ezcDbSchemaField::__set_state(array(
+           'type' => 'boolean',
+           'length' => 0,
+           'notNull' => false,
+           'default' => NULL,
+           'autoIncrement' => false,
+           'unsigned' => false,
+        )),
+      ),
+       'indexes' => 
+      array (
+      ),
+    )),
+  ),
+  1 => 
+  array (
+  ),
+); ?>

Modified: trunk/Database/tests/sqlabstraction/query_update_test.php
==============================================================================
--- trunk/Database/tests/sqlabstraction/query_update_test.php [iso-8859-1] 
(original)
+++ trunk/Database/tests/sqlabstraction/query_update_test.php [iso-8859-1] Tue 
Jan  8 13:34:53 2008
@@ -199,6 +199,77 @@
         $this->assertEquals( 70, (int)$result[1][3] );
     }
 
+    // test for bug 10777
+    function testUpdateWithFalseTest()
+    {
+        // create the database
+        $db = ezcDbInstance::get();
+        // open schema
+        $schema = ezcDbSchema::createFromFile( 'array', dirname( __FILE__ ) . 
'/files/bug10777.dba' );
+        $schema->writeToDb( $db );
+
+        // insert data
+        $q = $db->createInsertQuery();
+        $s = $q->insertInto( 'bug10777' )
+               ->set( 'bar', $q->bindValue( false, null, PDO::PARAM_BOOL ) )
+               ->prepare();
+        $s->execute();
+        $q = $db->createInsertQuery();
+        $s = $q->insertInto( 'bug10777' )
+               ->set( 'bar', $q->bindValue( true ) )
+               ->prepare();
+        $s->execute();
+
+        // first test: select with where being false.
+        $q = $db->createSelectQuery();
+        $s = $q->select( 'bar' )
+               ->from( 'bug10777' )
+               ->where( $q->expr->eq( 'bar', $q->bindValue( false, null, 
PDO::PARAM_BOOL ) ) )
+               ->prepare();
+        $s->execute();
+        $s->bindColumn( 1, $returnValue, PDO::PARAM_BOOL );
+        $s->fetch( PDO::FETCH_BOUND );
+        self::assertEquals( false, $returnValue );
+
+        // second test: update with set to true
+        $q = $db->createUpdateQuery();
+        $s = $q->update( 'bug10777' )
+               ->set( 'bar', $q->bindValue( true, null, PDO::PARAM_BOOL ) )
+               ->prepare();
+        $s->execute();
+
+        $q = $db->createSelectQuery();
+        $s = $q->select( 'bar' )
+               ->from( 'bug10777' )
+               ->prepare();
+        $s->execute();
+        $s->bindColumn( 1, $returnValue, PDO::PARAM_BOOL );
+
+        $s->fetch( PDO::FETCH_BOUND );
+        self::assertEquals( true, $returnValue );
+        $s->fetch( PDO::FETCH_BOUND );
+        self::assertEquals( true, $returnValue );
+
+        // third test: update with set to false
+        $q = $db->createUpdateQuery();
+        $s = $q->update( 'bug10777' )
+               ->set( 'bar', $q->bindValue( false, null, PDO::PARAM_BOOL ) )
+               ->prepare();
+        $s->execute();
+
+        $q = $db->createSelectQuery();
+        $s = $q->select( 'bar' )
+               ->from( 'bug10777' )
+               ->prepare();
+        $s->execute();
+        $s->bindColumn( 1, $returnValue, PDO::PARAM_BOOL );
+
+        $s->fetch( PDO::FETCH_BOUND );
+        self::assertEquals( false, $returnValue );
+        $s->fetch( PDO::FETCH_BOUND );
+        self::assertEquals( false, $returnValue );
+    }
+
     public static function suite()
     {
         return new PHPUnit_Framework_TestSuite( 'ezcQueryUpdateTest' );


-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to