public function testTransaction()
 {
     $con = \Propel::getConnection();
     $service = new TransactionLifeCycle();
     $a = new Book();
     $faulty = new Book();
     $b = new Book();
     $ctx = $this->setUpEventHandlers($service);
     $faulty->setRawTitle(new \stdClass());
     $con->beginTransaction();
     try {
         $a->save();
         $faulty->save();
         $b->save();
         $this->fail("Transaction handling");
     } catch (\Exception $e) {
         $con->rollBack();
     }
     $this->assertEquals(false, $a->commited || $a->rolledback, 'Commited and rolledback hooks are not run if DB transaction didn\'t commit');
     $this->assertClearCache($service);
     $faulty->setTitle("test");
     $faulty->enableTransactionError();
     $con->beginTransaction();
     try {
         $a->save();
         $faulty->save();
         $b->save();
         $con->commit();
         $this->fail("Transaction faulty commit handling");
     } catch (\Exception $e) {
         $con->rollBack();
     }
     $this->assertEquals(true, $a->rolledback, 'Commited model was rolled back');
     $this->assertEquals(false, $b->rolledback || $faulty->rolledback, 'Uncommited models were not rolled back');
     $this->assertClearCache($service);
     $con->beginTransaction();
     try {
         $a->save();
         $b->save();
         $con->commit();
     } catch (\Exception $e) {
         $this->fail("Successful commit");
     }
     $this->assertClearCache($service);
     $ctx = $this->setUpEventHandlers('connection.commit.pre', $service);
     $a->setTitle("test");
     $a->save();
     $this->assertEventTriggered('Transaction events on singular model', $ctx, 1);
     $this->assertClearCache($service, 'Single commit');
 }