clientRepository ->createQueryBuilder('c') ->delete() ->getQuery() ->execute(); $this->clients = []; } /** * @Given /^there exist following clients:$/ */ public function thereExistFollowingClients(TableNode $table) { foreach ($table as $row) { $client = $this->getClient($row['clientId']); if (!$client) { $client = new Client( clientId: Uuid::fromRfc4122($row['clientId']), name: $row['name'], initialBalance: intval($row['initialBalance']), currentBalance: intval($row['currentBalance']), ); $this->clientRepository->save($client); } $this->clients[$client->getClientId()->toRfc4122()] = $client; } } public function getClient(string $id): ?Client { return $this->clients[$id] ??= $this->clientRepository->find(Uuid::fromRfc4122($id)); } /** * @Given /^client with id "([^"]+)" should exist$/ */ public function clientWithIdShouldExist(string $clientId) { Assert::assertNotNull($this->getClient($clientId)); } /** * @Given /^client with id "([^"]+)" should have balance of (\d+)$/ */ public function clientWithIdShouldHaveBalanceOf(string $clientId, int $balance) { $client = $this->getClient($clientId); Assert::assertEquals($client->getBalance(), $balance); } }