Beispiel #1
0
 protected function setUp()
 {
     parent::setUp();
     $this->connection = get_test_connection();
     $this->connection->setName("Conn 1");
     //        $this->connection->setDebugLog(new FileLog());
     $this->connection->exec("DELETE FROM test");
     $this->connection->exec("DELETE FROM test2");
     $this->connection->resetQueryCount();
 }
Beispiel #2
0
 function testGroupRollback()
 {
     $txm = new \tinyorm\TxManager();
     $txm->registerConnection($this->connection)->registerConnection($this->connection2);
     try {
         $txm->atomic(function () {
             $this->connection->exec("INSERT INTO test (c_unique) VALUES ('val1')");
             $this->connection2->exec("INSERT INTO test (c_unique) VALUES ('val2')");
             throw new \Exception("TEST");
         });
         $this->fail("Expected exception throw");
     } catch (\Exception $e) {
         // 3: BEGIN; INSERT; ROLLBACK;
         $this->assertEquals(3, $this->connection->getQueryCount());
         $this->assertEquals(3, $this->connection2->getQueryCount());
         $this->assertRowCount("test", 0);
     }
 }