/** * Remove the notification and prevent rendering, when the update is installed * * @param INotification $notification * @param string $installedVersion * @throws \InvalidArgumentException When the update is already installed */ protected function updateAlreadyInstalledCheck(INotification $notification, $installedVersion) { if (version_compare($notification->getObjectId(), $installedVersion, '<=')) { $this->notificationManager->markProcessed($notification); throw new \InvalidArgumentException(); } }
public function testMarkProcessed() { /** @var \OCP\Notification\INotification|\PHPUnit_Framework_MockObject_MockObject $notification */ $notification = $this->getMockBuilder('OCP\\Notification\\INotification')->disableOriginalConstructor()->getMock(); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app */ $app = $this->getMockBuilder('OCP\\Notification\\IApp')->disableOriginalConstructor()->getMock(); $app->expects($this->once())->method('markProcessed')->with($notification); /** @var \OCP\Notification\IApp|\PHPUnit_Framework_MockObject_MockObject $app2 */ $app2 = $this->getMockBuilder('OCP\\Notification\\IApp')->disableOriginalConstructor()->getMock(); $app2->expects($this->once())->method('markProcessed')->with($notification); $this->manager->registerApp(function () use($app) { return $app; }); $this->manager->registerApp(function () use($app2) { return $app2; }); $this->manager->markProcessed($notification); }
/** * @param int $remoteShare */ public function processNotification($remoteShare) { $filter = $this->notificationManager->createNotification(); $filter->setApp('files_sharing')->setUser($this->uid)->setObject('remote_share', (int) $remoteShare); $this->notificationManager->markProcessed($filter); }
/** * Delete notifications for old updates * * @param string $app * @param string $version */ protected function deleteOutdatedNotifications($app, $version) { $notification = $this->notificationManager->createNotification(); $notification->setApp('updatenotification')->setObject($app, $version); $this->notificationManager->markProcessed($notification); }