public function testTransactionalFailsAndDoesNotGetAdded() { $clients = new Clients(5, 'John Doe', new DateTime('2014-12-11'), 3, [new DateTime('2014-12-16'), new DateTime('2014-12-31'), new DateTime('2015-03-11')], 25.125); $transaction = function () use($clients) { $this->repository->add($clients); throw new \Exception('Just making it fail'); }; try { $this->repository->transactional($transaction); } catch (\Exception $e) { $this->assertEquals(4, $this->repository->count()); } }