当前位置: 首页>>代码示例>>PHP>>正文


PHP IManager::expects方法代码示例

本文整理汇总了PHP中OCP\Activity\IManager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP IManager::expects方法的具体用法?PHP IManager::expects怎么用?PHP IManager::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\Activity\IManager的用法示例。


在下文中一共展示了IManager::expects方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     parent::setUp();
     $app = $this->getUniqueID('MailQueueHandlerTest');
     $this->userManager = $this->getMock('OCP\\IUserManager');
     $connection = \OC::$server->getDatabaseConnection();
     $query = $connection->prepare('INSERT INTO `*PREFIX*activity_mq` ' . ' (`amq_appid`, `amq_subject`, `amq_subjectparams`, `amq_affecteduser`, `amq_timestamp`, `amq_type`, `amq_latest_send`) ' . ' VALUES(?, ?, ?, ?, ?, ?, ?)');
     $query->execute(array($app, 'Test data', 'Param1', 'user1', 150, 'phpunit', 152));
     $query->execute(array($app, 'Test data', 'Param1', 'user1', 150, 'phpunit', 153));
     $query->execute(array($app, 'Test data', 'Param1', 'user2', 150, 'phpunit', 150));
     $query->execute(array($app, 'Test data', 'Param1', 'user2', 150, 'phpunit', 151));
     $query->execute(array($app, 'Test data', 'Param1', 'user3', 150, 'phpunit', 154));
     $query->execute(array($app, 'Test data', 'Param1', 'user3', 150, 'phpunit', 155));
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->any())->method('setApp')->willReturnSelf();
     $event->expects($this->any())->method('setType')->willReturnSelf();
     $event->expects($this->any())->method('setAffectedUser')->willReturnSelf();
     $event->expects($this->any())->method('setTimestamp')->willReturnSelf();
     $event->expects($this->any())->method('setSubject')->willReturnSelf();
     $this->activityManager = $this->getMockBuilder('OCP\\Activity\\IManager')->disableOriginalConstructor()->getMock();
     $this->activityManager->expects($this->any())->method('generateEvent')->willReturn($event);
     $this->dataHelper = $this->getMockBuilder('OCA\\Activity\\DataHelper')->disableOriginalConstructor()->getMock();
     $this->dataHelper->expects($this->any())->method('getParameters')->willReturn([]);
     $this->message = $this->getMockBuilder('OC\\Mail\\Message')->disableOriginalConstructor()->getMock();
     $this->mailer = $this->getMock('OCP\\Mail\\IMailer');
     $this->mailer->expects($this->any())->method('createMessage')->willReturn($this->message);
     $this->mailQueueHandler = new MailQueueHandler($this->getMock('\\OCP\\IDateTimeFormatter'), $connection, $this->dataHelper, $this->mailer, $this->getMockBuilder('\\OCP\\IURLGenerator')->disableOriginalConstructor()->getMock(), $this->userManager, $this->activityManager);
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:28,代码来源:mailqueuehandlertest.php

示例2: testAppActivity

 public function testAppActivity()
 {
     $this->activityManager->expects($this->once())->method('registerExtension')->willReturnCallback(function ($closure) {
         $this->assertInstanceOf('\\Closure', $closure);
         $navigation = $closure();
         $this->assertInstanceOf('\\OCA\\AnnouncementCenter\\ActivityExtension', $navigation);
     });
     include __DIR__ . '/../../appinfo/app.php';
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:9,代码来源:AppTest.php

示例3: testCreatePublicity

 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]);
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:28,代码来源:PageControllerTest.php

示例4: mockUserSession

 protected function mockUserSession($user)
 {
     $mockUser = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
     $mockUser->expects($this->any())->method('getUID')->willReturn($user);
     $this->session->expects($this->any())->method('isLoggedIn')->willReturn(true);
     $this->session->expects($this->any())->method('getUser')->willReturn($mockUser);
     $this->manager->expects($this->any())->method('getCurrentUserId')->willReturn($user);
 }
开发者ID:ynott,项目名称:activity,代码行数:8,代码来源:feedtest.php

示例5: testTranslate

 /**
  * @dataProvider dataTranslate
  *
  * @param string $app
  * @param string $text
  * @param array $params
  * @param bool $stripPath
  * @param bool $highlightParams
  * @param string $languageCode
  * @param mixed $managerReturn
  * @param string $currentUser
  * @param mixed $expected
  */
 public function testTranslate($app, $text, $params, $stripPath, $highlightParams, $languageCode, $managerReturn, $currentUser, $expected)
 {
     if ($managerReturn === null) {
         $this->manager->expects($this->never())->method('getAnnouncement');
     } else {
         $this->factory->expects($this->any())->method('get')->with('announcementcenter', $languageCode)->willReturn($this->l);
         $this->activity->expects($this->any())->method('getCurrentUserId')->willReturn($currentUser);
         if ($managerReturn === false) {
             $this->manager->expects($this->once())->method('getAnnouncement')->with(10, $highlightParams)->willThrowException(new \InvalidArgumentException());
         } else {
             $this->manager->expects($this->once())->method('getAnnouncement')->with(10, $highlightParams)->willReturn($managerReturn);
         }
     }
     $this->assertSame($expected, $this->extension->translate($app, $text, $params, $stripPath, $highlightParams, $languageCode));
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:28,代码来源:ActivityExtensionTest.php

示例6: testGetEventFromArray

 /**
  * @dataProvider dataGetEventFromArray
  * @param array $activity
  */
 public function testGetEventFromArray(array $activity)
 {
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('setApp')->with($activity['app'])->willReturnSelf();
     $event->expects($this->once())->method('setType')->with($activity['type'])->willReturnSelf();
     $event->expects($this->once())->method('setAffectedUser')->with($activity['affecteduser'])->willReturnSelf();
     $event->expects($this->once())->method('setAuthor')->with($activity['user'])->willReturnSelf();
     $event->expects($this->once())->method('setTimestamp')->with($activity['timestamp'])->willReturnSelf();
     $event->expects($this->once())->method('setSubject')->with($activity['subject'], $activity['subjectparams'])->willReturnSelf();
     $event->expects($this->once())->method('setMessage')->with($activity['message'], $activity['messageparams'])->willReturnSelf();
     $event->expects($this->once())->method('setObject')->with($activity['object_type'], $activity['object_id'], $activity['object_name'])->willReturnSelf();
     $event->expects($this->once())->method('setLink')->with($activity['link'])->willReturnSelf();
     $this->activityManager->expects($this->once())->method('generateEvent')->willReturn($event);
     $helper = $this->getHelper();
     $instance = $helper->getEventFromArray($activity);
     $this->assertSame($event, $instance);
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:21,代码来源:grouphelpertest.php

示例7: testAddNotificationsForUser

 /**
  * @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]);
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:39,代码来源:fileshookstest.php

示例8: testGetSpecialParameterList

 /**
  * @dataProvider dataGetSpecialParameterList
  *
  * @param string $app
  * @param string $text
  * @param array|bool $managerReturn
  * @param array $expected
  */
 public function testGetSpecialParameterList($app, $text, $managerReturn, array $expected)
 {
     $this->activityManager->expects($this->once())->method('getSpecialParameterList')->with($app, $text)->willReturn($managerReturn);
     $instance = $this->getHelper();
     $this->assertSame($expected, $this->invokePrivate($instance, 'getSpecialParameterList', [$app, $text]));
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:14,代码来源:datahelpertest.php


注:本文中的OCP\Activity\IManager::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。