@@ 224-289 (lines=66) @@ | ||
221 | $this->assertNull($this->domainManager->find($action, $repositoryMethod, $criteria, $sorting)); |
|
222 | } |
|
223 | ||
224 | public function testCreate() |
|
225 | { |
|
226 | $this->resource |
|
227 | ->expects($this->exactly(4)) |
|
228 | ->method('getName') |
|
229 | ->will($this->returnValue($name = 'name')); |
|
230 | ||
231 | $this->objectManager |
|
232 | ->expects($this->once()) |
|
233 | ->method('persist') |
|
234 | ->with($this->identicalTo($object = new \stdClass())); |
|
235 | ||
236 | $this->objectManager |
|
237 | ->expects($this->once()) |
|
238 | ->method('flush'); |
|
239 | ||
240 | $this->eventDispatcher |
|
241 | ->expects($this->at(0)) |
|
242 | ->method('dispatch') |
|
243 | ->with( |
|
244 | $this->identicalTo('lug.'.$name.'.pre_'.($createAction = 'create')), |
|
245 | $this->callback(function (DomainEvent $event) use ($createAction, $object) { |
|
246 | return $event->getResource() === $this->resource |
|
247 | && $event->getObject() === $object |
|
248 | && $event->getAction() === $createAction; |
|
249 | }) |
|
250 | ); |
|
251 | ||
252 | $this->eventDispatcher |
|
253 | ->expects($this->at(1)) |
|
254 | ->method('dispatch') |
|
255 | ->with( |
|
256 | $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')), |
|
257 | $this->callback(function (DomainEvent $event) use ($flushAction, $object) { |
|
258 | return $event->getResource() === $this->resource |
|
259 | && $event->getObject() === $object |
|
260 | && $event->getAction() === $flushAction; |
|
261 | }) |
|
262 | ); |
|
263 | ||
264 | $this->eventDispatcher |
|
265 | ->expects($this->at(2)) |
|
266 | ->method('dispatch') |
|
267 | ->with( |
|
268 | $this->identicalTo('lug.'.$name.'.post_'.$flushAction), |
|
269 | $this->callback(function (DomainEvent $event) use ($flushAction, $object) { |
|
270 | return $event->getResource() === $this->resource |
|
271 | && $event->getObject() === $object |
|
272 | && $event->getAction() === $flushAction; |
|
273 | }) |
|
274 | ); |
|
275 | ||
276 | $this->eventDispatcher |
|
277 | ->expects($this->at(3)) |
|
278 | ->method('dispatch') |
|
279 | ->with( |
|
280 | $this->identicalTo('lug.'.$name.'.post_'.$createAction), |
|
281 | $this->callback(function (DomainEvent $event) use ($object, $createAction) { |
|
282 | return $event->getResource() === $this->resource |
|
283 | && $event->getObject() === $object |
|
284 | && $event->getAction() === $createAction; |
|
285 | }) |
|
286 | ); |
|
287 | ||
288 | $this->domainManager->create($object); |
|
289 | } |
|
290 | ||
291 | public function testCreateWithoutFlush() |
|
292 | { |
|
@@ 830-895 (lines=66) @@ | ||
827 | $this->domainManager->update($object); |
|
828 | } |
|
829 | ||
830 | public function testDelete() |
|
831 | { |
|
832 | $this->resource |
|
833 | ->expects($this->exactly(4)) |
|
834 | ->method('getName') |
|
835 | ->will($this->returnValue($name = 'name')); |
|
836 | ||
837 | $this->objectManager |
|
838 | ->expects($this->once()) |
|
839 | ->method('remove') |
|
840 | ->with($this->identicalTo($object = new \stdClass())); |
|
841 | ||
842 | $this->objectManager |
|
843 | ->expects($this->once()) |
|
844 | ->method('flush'); |
|
845 | ||
846 | $this->eventDispatcher |
|
847 | ->expects($this->at(0)) |
|
848 | ->method('dispatch') |
|
849 | ->with( |
|
850 | $this->identicalTo('lug.'.$name.'.pre_'.($deleteAction = 'delete')), |
|
851 | $this->callback(function (DomainEvent $event) use ($deleteAction, $object) { |
|
852 | return $event->getResource() === $this->resource |
|
853 | && $event->getObject() === $object |
|
854 | && $event->getAction() === $deleteAction; |
|
855 | }) |
|
856 | ); |
|
857 | ||
858 | $this->eventDispatcher |
|
859 | ->expects($this->at(1)) |
|
860 | ->method('dispatch') |
|
861 | ->with( |
|
862 | $this->identicalTo('lug.'.$name.'.pre_'.($flushAction = 'flush')), |
|
863 | $this->callback(function (DomainEvent $event) use ($flushAction, $object) { |
|
864 | return $event->getResource() === $this->resource |
|
865 | && $event->getObject() === $object |
|
866 | && $event->getAction() === $flushAction; |
|
867 | }) |
|
868 | ); |
|
869 | ||
870 | $this->eventDispatcher |
|
871 | ->expects($this->at(2)) |
|
872 | ->method('dispatch') |
|
873 | ->with( |
|
874 | $this->identicalTo('lug.'.$name.'.post_'.$flushAction), |
|
875 | $this->callback(function (DomainEvent $event) use ($flushAction, $object) { |
|
876 | return $event->getResource() === $this->resource |
|
877 | && $event->getObject() === $object |
|
878 | && $event->getAction() === $flushAction; |
|
879 | }) |
|
880 | ); |
|
881 | ||
882 | $this->eventDispatcher |
|
883 | ->expects($this->at(3)) |
|
884 | ->method('dispatch') |
|
885 | ->with( |
|
886 | $this->identicalTo('lug.'.$name.'.post_'.$deleteAction), |
|
887 | $this->callback(function (DomainEvent $event) use ($object, $deleteAction) { |
|
888 | return $event->getResource() === $this->resource |
|
889 | && $event->getObject() === $object |
|
890 | && $event->getAction() === $deleteAction; |
|
891 | }) |
|
892 | ); |
|
893 | ||
894 | $this->domainManager->delete($object); |
|
895 | } |
|
896 | ||
897 | public function testDeleteWithoutFlush() |
|
898 | { |