/** * Save notification * * @param NotificationInterface $notification * @return NotificationInterface */ public function save(NotificationInterface $notification) { $this->eventService->fire('user.notifications.save.pre', ['notification' => $notification]); $result = $this->notificationMapper->save($notification); $this->eventService->fire('user.notifications.save.post', ['notification' => $notification]); return $result; }
public function testSave() { /** @var NotificationInterface $notification */ $notification = $this->getMock(NotificationInterface::class); $this->eventService->expects($this->at(0))->method('fire')->with('user.notifications.save.pre', ['notification' => $notification]); $this->eventService->expects($this->at(1))->method('fire')->with('user.notifications.save.post', ['notification' => $notification]); $this->notificationMapper->expects($this->at(0))->method('save')->with($notification)->willReturn($notification); $result = $this->service->save($notification); $this->assertSame($notification, $result); }