Exemple #1
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testPrepareNoNotifier()
 {
     /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
     $notification = $this->getMockBuilder('OCP\\Notification\\INotification')->disableOriginalConstructor()->getMock();
     $notification->expects($this->once())->method('isValidParsed')->willReturn(false);
     $this->manager->prepare($notification, 'en');
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @param array $parameters
  * @return \OC_OCS_Result
  */
 public function getNotification(array $parameters)
 {
     if (!$this->manager->hasNotifiers()) {
         return new \OC_OCS_Result(null, Http::STATUS_NOT_FOUND);
     }
     if (!isset($parameters['id'])) {
         return new \OC_OCS_Result(null, HTTP::STATUS_NOT_FOUND);
     }
     $id = (int) $parameters['id'];
     $notification = $this->handler->getById($id, $this->getCurrentUser());
     if (!$notification instanceof INotification) {
         return new \OC_OCS_Result(null, HTTP::STATUS_NOT_FOUND);
     }
     $language = $this->config->getUserValue($this->getCurrentUser(), 'core', 'lang', null);
     try {
         $notification = $this->manager->prepare($notification, $language);
     } catch (\InvalidArgumentException $e) {
         // The app was disabled
         return new \OC_OCS_Result(null, HTTP::STATUS_NOT_FOUND);
     }
     return new \OC_OCS_Result($this->notificationToArray($id, $notification), 100);
 }