/** * @expectedException \InvalidArgumentException */ public function testNotifyInvalid() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ $notification = $this->getMockBuilder('OCP\\Notification\\INotification')->disableOriginalConstructor()->getMock(); $notification->expects($this->once())->method('isValid')->willReturn(false); $this->manager->notify($notification); }
/** * Create notifications for this app version * * @param string $app * @param string $version * @param string $url */ protected function createNotifications($app, $version, $url) { $lastNotification = $this->config->getAppValue('updatenotification', $app, false); if ($lastNotification === $version) { // We already notified about this update return; } else { if ($lastNotification !== false) { // Delete old updates $this->deleteOutdatedNotifications($app, $lastNotification); } } $notification = $this->notificationManager->createNotification(); $notification->setApp('updatenotification')->setDateTime(new \DateTime())->setObject($app, $version)->setSubject('update_available')->setLink($url); foreach ($this->getUsersToNotify() as $uid) { $notification->setUser($uid); $this->notificationManager->notify($notification); } $this->config->setAppValue('updatenotification', $app, $version); }