コード例 #1
0
 public function testDeleteById()
 {
     $notification = $this->getNotification(['getApp' => 'testing_notifications', 'getUser' => 'test_user1', 'getTimestamp' => time(), 'getObjectType' => 'notification', 'getObjectId' => 1337, 'getSubject' => 'subject', 'getSubjectParameters' => [], 'getMessage' => 'message', 'getMessageParameters' => [], 'getLink' => 'link', 'getIcon' => 'icon', 'getActions' => [['getLabel' => 'action_label', 'getIcon' => 'action_icon', 'getLink' => 'action_link', 'getRequestType' => 'GET']]]);
     $limitedNotification = $this->getNotification(['getApp' => 'testing_notifications', 'getUser' => 'test_user1']);
     // Make sure there is no notification
     $this->assertSame(0, $this->handler->count($limitedNotification));
     $notifications = $this->handler->get($limitedNotification);
     $this->assertCount(0, $notifications);
     // Add and count
     $this->handler->add($notification);
     $this->assertSame(1, $this->handler->count($limitedNotification));
     // Get and count
     $notifications = $this->handler->get($limitedNotification);
     $this->assertCount(1, $notifications);
     reset($notifications);
     $notificationId = key($notifications);
     // Delete with wrong user
     $this->handler->deleteById($notificationId, 'test_user2');
     $this->assertSame(1, $this->handler->count($limitedNotification), 'Wrong notification count for user1 after trying to delete for user2');
     // Delete and count
     $this->handler->deleteById($notificationId, 'test_user1');
     $this->assertSame(0, $this->handler->count($limitedNotification), 'Wrong notification count for user1 after deleting');
 }
コード例 #2
0
ファイル: App.php プロジェクト: drognisep/Portfolio-Site
 /**
  * @param INotification $notification
  * @return int
  * @since 8.2.0
  */
 public function getCount(INotification $notification)
 {
     return $this->handler->count($notification);
 }