@@ 246-270 (lines=25) @@ | ||
243 | /** |
|
244 | * Test remove. |
|
245 | */ |
|
246 | public function testRemove() |
|
247 | { |
|
248 | $this |
|
249 | ->given($repository = $this->randomRepository()) |
|
250 | ->and($unique = $this->uniqueValue()) |
|
251 | ->when($repository->persist($unique)) |
|
252 | ->then() |
|
253 | ->object($repository->get($unique->id())) |
|
254 | ->isEqualTo($unique) |
|
255 | ->and() |
|
256 | ->when($repository->remove($unique)) |
|
257 | ->then() |
|
258 | ->variable($repository->get($unique->id())) |
|
259 | ->isNull() |
|
260 | ; |
|
261 | ||
262 | $this |
|
263 | ->given($repository = $this->randomRepository()) |
|
264 | ->given($id = UserId::next()) |
|
265 | ->then() |
|
266 | ->exception(function () use ($repository, $id) { |
|
267 | $repository->remove($id); |
|
268 | })->isInstanceOf(\InvalidArgumentException::class) |
|
269 | ; |
|
270 | } |
|
271 | ||
272 | /** |
|
273 | * Test findOne. |
@@ 245-269 (lines=25) @@ | ||
242 | /** |
|
243 | * Test remove. |
|
244 | */ |
|
245 | public function testRemove() |
|
246 | { |
|
247 | $this |
|
248 | ->given($repository = $this->randomRepository()) |
|
249 | ->and($unique = $this->uniqueValue()) |
|
250 | ->when($repository->persist($unique)) |
|
251 | ->then() |
|
252 | ->object($repository->get($unique->id())) |
|
253 | ->isEqualTo($unique) |
|
254 | ->and() |
|
255 | ->when($repository->remove($unique)) |
|
256 | ->then() |
|
257 | ->variable($repository->get($unique->id())) |
|
258 | ->isNull() |
|
259 | ; |
|
260 | ||
261 | $this |
|
262 | ->given($repository = $this->randomRepository()) |
|
263 | ->given($id = UserId::next()) |
|
264 | ->then() |
|
265 | ->exception(function () use ($repository, $id) { |
|
266 | $repository->remove($id); |
|
267 | })->isInstanceOf(\InvalidArgumentException::class) |
|
268 | ; |
|
269 | } |
|
270 | } |
|
271 |