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


PHP MockInterface::shouldHaveReceived方法代码示例

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


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

示例1: testValidateFail

 public function testValidateFail()
 {
     $menu = new AuthenticatedMenu();
     $menu->setContainer($this->container);
     $this->container->shouldReceive('get')->once()->withArgs(['security.authorization_checker'])->andReturn($this->security);
     $this->security->shouldReceive('isGranted')->once()->withArgs(['IS_AUTHENTICATED_REMEMBERED'])->andReturn(false);
     $this->assertFalse($menu->validate());
     $this->security->shouldHaveReceived('isGranted')->once()->withArgs(['IS_AUTHENTICATED_REMEMBERED']);
 }
开发者ID:csbill,项目名称:csbill,代码行数:9,代码来源:AuthenticatedMenuTest.php

示例2: testAddRootUser

 /**
  * @covers \Ilios\CliBundle\Command\AddRootUserCommand::execute
  */
 public function testAddRootUser()
 {
     $userId = 1;
     $user = m::mock('Ilios\\CoreBundle\\Entity\\User');
     $this->userManager->shouldReceive('findOneBy')->with(['id' => $userId])->andReturn($user);
     $this->userManager->shouldReceive('update');
     $user->shouldReceive('setRoot');
     $this->commandTester->execute(['command' => AddRootUserCommand::COMMAND_NAME, 'userId' => $userId]);
     $this->userManager->shouldHaveReceived('update', [$user, true, true]);
     $user->shouldHaveReceived('setRoot', [true]);
     $output = $this->commandTester->getDisplay();
     $this->assertEquals("User with id #{$userId} has been granted root-level privileges.", trim($output));
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:16,代码来源:AddRootUserCommandTest.php

示例3: testCommandPrintsOutNewCourseIdOnSuccess

 public function testCommandPrintsOutNewCourseIdOnSuccess()
 {
     $courseId = '1';
     $newAcademicYear = '2017';
     $newCourseId = 5;
     $this->service->shouldReceive('rolloverCourse')->andReturnUsing(function () use($newCourseId) {
         $course = new Course();
         $course->setId($newCourseId);
         return $course;
     });
     $this->commandTester->execute(['command' => self::COMMAND_NAME, 'courseId' => $courseId, 'newAcademicYear' => $newAcademicYear]);
     $this->service->shouldHaveReceived('rolloverCourse')->withAnyArgs()->once();
     $output = $this->commandTester->getDisplay();
     $this->assertEquals("This course has been rolled over. The new course id is {$newCourseId}.", trim($output));
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:15,代码来源:RolloverCourseCommandTest.php

示例4: testTrackingFailure

 /**
  * @covers \Ilios\CoreBundle\EventListener\TrackApiUsageListener::onKernelController
  */
 public function testTrackingFailure()
 {
     $uri = '/api/v1/foo/bar/baz';
     $host = 'iliosproject.org';
     $e = new \Exception();
     $this->mockRequest->shouldReceive('getRequestUri')->andReturn($uri);
     $this->mockRequest->shouldReceive('getHost')->andReturn($host);
     $this->mockTracker->shouldReceive('send')->andReturnUsing(function () use($e) {
         throw $e;
     });
     $listener = new TrackApiUsageListener(true, $this->mockTracker, $this->mockLogger);
     $listener->onKernelController($this->mockEvent);
     $this->mockLogger->shouldHaveReceived('error')->withArgs(['Failed to send tracking data.', ['exception' => $e]]);
     unset($mockLogger);
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:18,代码来源:TrackApiUsageListenerTest.php

示例5: testCommandPrintsOutNewReportIdOnSuccess

 public function testCommandPrintsOutNewReportIdOnSuccess()
 {
     $reportId = '1';
     $newReportId = 5;
     $this->service->shouldReceive('rollover')->andReturnUsing(function () use($newReportId) {
         $report = new CurriculumInventoryReport();
         $report->setId($newReportId);
         return $report;
     });
     $this->reportManager->shouldReceive('findOneBy')->with(['id' => $reportId])->andReturnUsing(function () use($reportId) {
         $report = new CurriculumInventoryReport();
         $report->setId($reportId);
         return $report;
     });
     $this->commandTester->execute(['command' => self::COMMAND_NAME, 'reportId' => $reportId]);
     $this->service->shouldHaveReceived('rollover')->withAnyArgs()->once();
     $output = $this->commandTester->getDisplay();
     $this->assertEquals("The given report has been rolled over. The new report id is {$newReportId}.", trim($output));
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:19,代码来源:RolloverCurriculumInventoryReportCommandTest.php

示例6: canBeInitialized

 /**
  * @return @test
  */
 public function canBeInitialized()
 {
     $this->body->shouldReceive('__toString')->andReturn('');
     $this->assertEmpty($this->response->getContent());
     $this->body->shouldHaveReceived('__toString')->withNoArgs();
 }
开发者ID:abava,项目名称:http,代码行数:9,代码来源:ResponseTest.php

示例7: testKernelGetsBooted

 public function testKernelGetsBooted()
 {
     new Application($this->kernel);
     $this->kernel->shouldHaveReceived('boot')->once();
 }
开发者ID:havvg,项目名称:psi,代码行数:5,代码来源:ApplicationTest.php


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