@@ 198-241 (lines=44) @@ | ||
195 | /** |
|
196 | * Test persistAll. |
|
197 | */ |
|
198 | public function testPersistAll() |
|
199 | { |
|
200 | $this |
|
201 | ->given($repository = $this->emptyRepository()) |
|
202 | ->and($unique = $this->uniqueValue()) |
|
203 | ->and($random = $this->randomValue()) |
|
204 | ->then() |
|
205 | ->variable($repository->get($unique->id())) |
|
206 | ->isNull() |
|
207 | ->variable($repository->get($random->id())) |
|
208 | ->isNull() |
|
209 | ->and() |
|
210 | ->when($repository->persistAll([$unique, $random])) |
|
211 | ->then() |
|
212 | ->object($repository->get($unique->id())) |
|
213 | ->isEqualTo($unique) |
|
214 | ->object($repository->get($random->id())) |
|
215 | ->isEqualTo($random) |
|
216 | ; |
|
217 | ||
218 | $this |
|
219 | ->given($repository = $this->randomRepository()) |
|
220 | ->given($id = UserId::next()) |
|
221 | ->then() |
|
222 | ->exception(function () use ($repository, $id) { |
|
223 | $repository->persistAll([$id]); |
|
224 | })->isInstanceOf(\InvalidArgumentException::class) |
|
225 | ; |
|
226 | ||
227 | $this |
|
228 | ->given($repository = $this->emptyRepository()) |
|
229 | ->and($value = $this->randomValue()) |
|
230 | ->and($age = $value->age()) |
|
231 | ->when(function () use ($repository, $value, $age) { |
|
232 | $repository->persistAll([$value]); |
|
233 | $value->setAge($age + 1); |
|
234 | $repository->persistAll([$value]); |
|
235 | }) |
|
236 | ->then() |
|
237 | ->object($other = $repository->get($value->id())) |
|
238 | ->integer($other->age()) |
|
239 | ->isEqualTo($age + 1) |
|
240 | ; |
|
241 | } |
|
242 | ||
243 | /** |
|
244 | * Test remove. |
@@ 197-240 (lines=44) @@ | ||
194 | /** |
|
195 | * Test persistAll. |
|
196 | */ |
|
197 | public function testPersistAll() |
|
198 | { |
|
199 | $this |
|
200 | ->given($repository = $this->emptyRepository()) |
|
201 | ->and($unique = $this->uniqueValue()) |
|
202 | ->and($random = $this->randomValue()) |
|
203 | ->then() |
|
204 | ->variable($repository->get($unique->id())) |
|
205 | ->isNull() |
|
206 | ->variable($repository->get($random->id())) |
|
207 | ->isNull() |
|
208 | ->and() |
|
209 | ->when($repository->persistAll([$unique, $random])) |
|
210 | ->then() |
|
211 | ->object($repository->get($unique->id())) |
|
212 | ->isEqualTo($unique) |
|
213 | ->object($repository->get($random->id())) |
|
214 | ->isEqualTo($random) |
|
215 | ; |
|
216 | ||
217 | $this |
|
218 | ->given($repository = $this->randomRepository()) |
|
219 | ->given($id = UserId::next()) |
|
220 | ->then() |
|
221 | ->exception(function () use ($repository, $id) { |
|
222 | $repository->persistAll([$id]); |
|
223 | })->isInstanceOf(\InvalidArgumentException::class) |
|
224 | ; |
|
225 | ||
226 | $this |
|
227 | ->given($repository = $this->emptyRepository()) |
|
228 | ->and($value = $this->randomValue()) |
|
229 | ->and($age = $value->age()) |
|
230 | ->when(function () use ($repository, $value, $age) { |
|
231 | $repository->persistAll([$value]); |
|
232 | $value->setAge($age + 1); |
|
233 | $repository->persistAll([$value]); |
|
234 | }) |
|
235 | ->then() |
|
236 | ->object($other = $repository->get($value->id())) |
|
237 | ->integer($other->age()) |
|
238 | ->isEqualTo($age + 1) |
|
239 | ; |
|
240 | } |
|
241 | ||
242 | /** |
|
243 | * Test remove. |