Making the two MySQL tests create an InnoDB database so that we can practice our...
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 15 Aug 2007 07:06:17 +0000 (07:06 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 15 Aug 2007 07:06:17 +0000 (07:06 +0000)
* UnitTest/DatabaseMySQLTest.php:
(DatabaseMySQLTest::setUp): Create the test table as InnoDB
* UnitTest/DatabaseMySQLiTest.php:
(DatabaseMySQLiTest::setUp): ditto
* UnitTest/DatabaseTestAbstract.php:
(DatabaseTestAbstract::testTransactions): New method

UnitTest/DatabaseMySQLTest.php
UnitTest/DatabaseMySQLiTest.php
UnitTest/DatabaseTestAbstract.php

index d3cf1c570342437e147b48dfa32d73059c12050e..9fe1c5c47bae03fe428b0419137a50e6ddc3e15e 100644 (file)
@@ -18,7 +18,7 @@ class DatabaseMySQLTest extends DatabaseTestAbstract
                                id int auto_increment,
                                textstuff varchar(255),
                                PRIMARY KEY (id)
-                       )
+                       ) ENGINE=InnoDb
                ");
        }
        
index 63e850936d6b6253ae8d59a94e8a19c3bdd67d22..1e803a9fa90e7dc0ad3bfd6d661052bb5be78f90 100644 (file)
@@ -18,7 +18,7 @@ class DatabaseMySQLiTest extends DatabaseTestAbstract
                                id int auto_increment,
                                textstuff varchar(255),
                                PRIMARY KEY (id)
-                       )
+                       ) Engine=InnoDB
                ");
        }
        
index 31f57a9063f29f47ae14ee620c920ee1503c7279..e5285f05a9a77fb30a65e04ba2ab193cdd8fca6d 100644 (file)
@@ -162,6 +162,26 @@ abstract class DatabaseTestAbstract extends PHPUnit_Framework_TestCase
                        $this->assertEquals('SELECT * FROM foobar', $e->getQuery());
                }
        }
+       
+       public function testTransactions()
+       {
+               $this->fixture->begin();
+               $this->fixture->query("INSERT INTO test (textstuff) VALUES ('foo')");
+               $this->fixture->commit();
+               
+               $res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'foo'");
+               $this->assertEquals(1, $this->fixture->numRows($res));
+               
+               $this->fixture->begin();
+               $this->fixture->query("UPDATE test SET textstuff = 'abc'");
+               $this->fixture->rollback();
+               
+               $res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'abc'");
+               $this->assertEquals(0, $this->fixture->numRows($res));
+               
+               $res = $this->fixture->query("SELECT * FROM test WHERE textstuff = 'foo'");
+               $this->assertEquals(1, $this->fixture->numRows($res));
+       }
 }
 
 ?>
\ No newline at end of file