本文整理汇总了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']);
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}
示例6: canBeInitialized
/**
* @return @test
*/
public function canBeInitialized()
{
$this->body->shouldReceive('__toString')->andReturn('');
$this->assertEmpty($this->response->getContent());
$this->body->shouldHaveReceived('__toString')->withNoArgs();
}
示例7: testKernelGetsBooted
public function testKernelGetsBooted()
{
new Application($this->kernel);
$this->kernel->shouldHaveReceived('boot')->once();
}