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()); } }
/** * Returns the total amount of elements in the repository given the restrictions provided by the Filter object. * * @param Filter|null $filter * * @return int */ public function count(Filter $filter = null) : int { return parent::count($filter); }