Beispiel #1
0
 public function testAddParsedAction()
 {
     /** @var \OCP\Notification\IAction|\PHPUnit_Framework_MockObject_MockObject $action */
     $action = $this->getMockBuilder('OCP\\Notification\\IAction')->disableOriginalConstructor()->getMock();
     $action->expects($this->once())->method('isValidParsed')->willReturn(true);
     $action->expects($this->never())->method('isValid');
     $this->assertSame($this->notification, $this->notification->addParsedAction($action));
     $this->assertEquals([$action], $this->notification->getParsedActions());
     $this->assertEquals([], $this->notification->getActions());
 }
 /**
  * @param int $notificationId
  * @param INotification $notification
  * @return array
  */
 protected function notificationToArray($notificationId, INotification $notification)
 {
     $data = ['notification_id' => $notificationId, 'app' => $notification->getApp(), 'user' => $notification->getUser(), 'datetime' => $notification->getDateTime()->format('c'), 'object_type' => $notification->getObjectType(), 'object_id' => $notification->getObjectId(), 'subject' => $notification->getParsedSubject(), 'message' => $notification->getParsedMessage(), 'link' => $notification->getLink(), 'actions' => []];
     foreach ($notification->getParsedActions() as $action) {
         $data['actions'][] = $this->actionToArray($action);
     }
     return $data;
 }