/**
  * @dataProvider dataDelete
  * @param int $id
  * @param string $username
  */
 public function testDelete($id, $username)
 {
     $controller = $this->getController([], $username);
     $this->handler->expects($this->once())->method('deleteById')->with($id, $username);
     $response = $controller->delete($id);
     $this->assertInstanceOf('OCP\\AppFramework\\Http\\Response', $response);
     $this->assertSame(Http::STATUS_OK, $response->getStatus());
 }
 /**
  * @NoAdminRequired
  *
  * @param array $parameters
  * @return \OC_OCS_Result
  */
 public function deleteNotification(array $parameters)
 {
     if (!isset($parameters['id'])) {
         return new \OC_OCS_Result(null, HTTP::STATUS_NOT_FOUND);
     }
     $id = (int) $parameters['id'];
     $this->handler->deleteById($id, $this->getCurrentUser());
     return new \OC_OCS_Result();
 }
 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');
 }
Beispiel #4
0
 /**
  * @param INotification $notification
  * @return null
  * @since 8.2.0
  */
 public function markProcessed(INotification $notification)
 {
     $this->handler->delete($notification);
 }
 /**
  * @NoAdminRequired
  *
  * @param int $id
  * @return Response
  */
 public function delete($id)
 {
     $this->handler->deleteById($id, $this->user);
     return new Response();
 }
 public function testMarkProcessed()
 {
     $this->handler->expects($this->once())->method('delete')->with($this->notification);
     $this->app->markProcessed($this->notification);
 }