/** * Test error in transcation callback. */ public function testErrorInTransactionCallback() { $this->assertEquals(3, $this->connection->executeFirstCell('SELECT COUNT(`id`) AS "row_count" FROM `writers`')); /** @var Exception $exception_caught */ $exception_caught = false; $this->connection->transact(function () { $this->connection->execute('INSERT INTO `writers` (`name`, `birthday`) VALUES (?, ?)', 'Anton Chekhov', new DateTime('1860-01-29')); throw new RuntimeException('Throwing an exception here'); }, null, function (Exception $e) use(&$exception_caught) { $exception_caught = $e; }); $this->assertInstanceOf('\\RuntimeException', $exception_caught); $this->assertEquals('Throwing an exception here', $exception_caught->getMessage()); $this->assertEquals(3, $this->connection->executeFirstCell('SELECT COUNT(`id`) AS "row_count" FROM `writers`')); }