示例#1
0
 protected function setUp()
 {
     parent::setUp();
     $this->deleteTestActivities();
     $this->userSettings = $this->getMockBuilder('OCA\\Activity\\UserSettings')->setMethods(array('getUserSetting'))->disableOriginalConstructor()->getMock();
     $this->userSettings->expects($this->any())->method('getUserSetting')->with($this->stringContains('affectedUser'), $this->anything(), $this->anything())->will($this->returnValueMap(array(array('affectedUser', 'stream', 'type', true), array('affectedUser2', 'stream', 'type', true), array('affectedUser', 'setting', 'self', true), array('affectedUser2', 'setting', 'self', false), array('affectedUser', 'email', 'type', true), array('affectedUser2', 'email', 'type', true), array('affectedUser', 'setting', 'selfemail', true), array('affectedUser2', 'setting', 'selfemail', false), array('affectedUser', 'setting', 'batchtime', 10), array('affectedUser2', 'setting', 'batchtime', 10))));
 }
示例#2
0
 /**
  * @dataProvider dataAddNotificationsForUser
  *
  * @param string $user
  * @param string $subject
  * @param array $parameter
  * @param int $fileId
  * @param string $path
  * @param bool $isFile
  * @param bool $stream
  * @param bool $email
  * @param int $type
  * @param bool $selfSetting
  * @param bool $selfEmailSetting
  * @param string $app
  * @param bool $sentStream
  * @param bool $sentEmail
  */
 public function testAddNotificationsForUser($user, $subject, $parameter, $fileId, $path, $isFile, $stream, $email, $type, $selfSetting, $selfEmailSetting, $app, $sentStream, $sentEmail)
 {
     $this->settings->expects($this->any())->method('getUserSetting')->willReturnMap([[$user, 'setting', 'self', $selfSetting], [$user, 'setting', 'selfemail', $selfEmailSetting]]);
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('setApp')->with($app)->willReturnSelf();
     $event->expects($this->once())->method('setType')->with($type)->willReturnSelf();
     $event->expects($this->once())->method('setAffectedUser')->with($user)->willReturnSelf();
     $event->expects($this->once())->method('setAuthor')->with('user')->willReturnSelf();
     $event->expects($this->once())->method('setTimestamp')->willReturnSelf();
     $event->expects($this->once())->method('setSubject')->with($subject, $parameter)->willReturnSelf();
     $event->expects($this->once())->method('setLink')->willReturnSelf();
     if ($fileId) {
         $event->expects($this->once())->method('setObject')->with('files', $fileId, $path)->willReturnSelf();
     } else {
         $event->expects($this->once())->method('setObject')->with('', $fileId, $path)->willReturnSelf();
     }
     $this->activityManager->expects($this->once())->method('generateEvent')->willReturn($event);
     $this->data->expects($sentStream ? $this->once() : $this->never())->method('send')->with($event);
     $this->data->expects($sentEmail ? $this->once() : $this->never())->method('storeMail')->with($event, $this->anything());
     $this->invokePrivate($this->filesHooks, 'addNotificationsForUser', [$user, $subject, $parameter, $fileId, $path, $isFile, $stream, $email, $type]);
 }