public function testRegisterApp()
 {
     $this->manager->expects($this->once())->method('registerApp')->willReturnCallback(function ($closure) {
         $this->assertInstanceOf('\\Closure', $closure);
         $navigation = $closure();
         $this->assertInstanceOf('\\OCA\\Notifications\\App', $navigation);
     });
     include __DIR__ . '/../../appinfo/app.php';
 }
 public function testCreatePublicity()
 {
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('setApp')->with('announcementcenter')->willReturnSelf();
     $event->expects($this->once())->method('setType')->with('announcementcenter')->willReturnSelf();
     $event->expects($this->once())->method('setAuthor')->with('author')->willReturnSelf();
     $event->expects($this->once())->method('setTimestamp')->with(1337)->willReturnSelf();
     $event->expects($this->once())->method('setSubject')->with('announcementsubject#10', ['author'])->willReturnSelf();
     $event->expects($this->once())->method('setMessage')->with('announcementmessage#10', ['author'])->willReturnSelf();
     $event->expects($this->once())->method('setObject')->with('announcement', 10)->willReturnSelf();
     $event->expects($this->exactly(5))->method('setAffectedUser')->willReturnSelf();
     $notification = $this->getMockBuilder('OC\\Notification\\INotification')->disableOriginalConstructor()->getMock();
     $notification->expects($this->once())->method('setApp')->with('announcementcenter')->willReturnSelf();
     $dateTime = new \DateTime();
     $dateTime->setTimestamp(1337);
     $notification->expects($this->once())->method('setDateTime')->with($dateTime)->willReturnSelf();
     $notification->expects($this->once())->method('setSubject')->with('announced', ['author'])->willReturnSelf();
     $notification->expects($this->once())->method('setObject')->with('announcement', 10)->willReturnSelf();
     $notification->expects($this->once())->method('setLink')->willReturnSelf();
     $notification->expects($this->exactly(4))->method('setUser')->willReturnSelf();
     $controller = $this->getController();
     $this->activityManager->expects($this->once())->method('generateEvent')->willReturn($event);
     $this->notificationManager->expects($this->once())->method('createNotification')->willReturn($notification);
     $this->userManager->expects($this->once())->method('search')->with('')->willReturn([$this->getUserMock('author', 'User One'), $this->getUserMock('u2', 'User Two'), $this->getUserMock('u3', 'User Three'), $this->getUserMock('u4', 'User Four'), $this->getUserMock('u5', 'User Five')]);
     $this->activityManager->expects($this->exactly(5))->method('publish');
     $this->notificationManager->expects($this->exactly(4))->method('notify');
     $this->invokePrivate($controller, 'createPublicity', [10, 'author', 1337]);
 }
 public function testGetNoNotifiers()
 {
     $controller = $this->getController();
     $this->manager->expects($this->once())->method('hasNotifiers')->willReturn(false);
     $response = $controller->get();
     $this->assertInstanceOf('OCP\\AppFramework\\Http\\Response', $response);
     $this->assertSame(Http::STATUS_NO_CONTENT, $response->getStatus());
 }