本文整理汇总了PHP中Prophecy\Prophecy\ObjectProphecy类的典型用法代码示例。如果您正苦于以下问题:PHP ObjectProphecy类的具体用法?PHP ObjectProphecy怎么用?PHP ObjectProphecy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectProphecy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Tests that there were no calls made.
*
* @param Call[] $calls
* @param ObjectProphecy $object
* @param MethodProphecy $method
*
* @throws \Prophecy\Exception\Prediction\UnexpectedCallsException
*/
public function check(array $calls, ObjectProphecy $object, MethodProphecy $method)
{
if (!count($calls)) {
return;
}
throw new UnexpectedCallsException(sprintf("No calls expected that match:\n" . " %s->%s(%s)\n" . "but %d were made:\n%s", get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard(), count($calls), $this->util->stringifyCalls($calls)), $method, $calls);
}
示例2: buildFakeObject
/**
* Builds a fake object using Prophecy
*/
public function buildFakeObject()
{
if (!isset($this->prophecy)) {
$this->initProphecy();
}
return $this->prophecy->reveal();
}
示例3: testInvokesSignatureVerifier
public function testInvokesSignatureVerifier()
{
$expected = new GnupgVerificationResult(['fingerprint' => 'foobar', 'summary' => 'baz']);
$this->verifier->verify('foo', 'bar')->willReturn($expected);
$service = new SignatureService($this->verifier->reveal());
$this->assertEquals($expected, $service->verify('foo', 'bar'));
}
示例4: datesAreReadFromQuery
/**
* @test
*/
public function datesAreReadFromQuery()
{
$shortCode = 'abc123';
$this->visitsTracker->info($shortCode, new DateRange(null, new \DateTime('2016-01-01 00:00:00')))->willReturn([])->shouldBeCalledTimes(1);
$response = $this->action->__invoke(ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode)->withQueryParams(['endDate' => '2016-01-01 00:00:00']), new Response());
$this->assertEquals(200, $response->getStatusCode());
}
示例5: setUp
/**
* Create a new database connection mock object for every test.
*
* @return void
*/
protected function setUp()
{
parent::setUp();
$this->typoScriptFrontendController = $this->prophesize(TypoScriptFrontendController::class);
$GLOBALS['TSFE'] = $this->typoScriptFrontendController->reveal();
$this->subject = GeneralUtility::makeInstance(QueryContext::class);
}
示例6: tagsListIsReturnedIfCorrectShortCodeIsProvided
/**
* @test
*/
public function tagsListIsReturnedIfCorrectShortCodeIsProvided()
{
$shortCode = 'abc123';
$this->shortUrlService->setTagsByShortCode($shortCode, [])->willReturn(new ShortUrl())->shouldBeCalledTimes(1);
$response = $this->action->__invoke(ServerRequestFactory::fromGlobals()->withAttribute('shortCode', 'abc123')->withParsedBody(['tags' => []]), new Response());
$this->assertEquals(200, $response->getStatusCode());
}
示例7: invalidApiKeyReturnsErrorResponse
/**
* @test
*/
public function invalidApiKeyReturnsErrorResponse()
{
$this->apiKeyService->getByKey('foo')->willReturn((new ApiKey())->setEnabled(false))->shouldBeCalledTimes(1);
$request = ServerRequestFactory::fromGlobals()->withParsedBody(['apiKey' => 'foo']);
$response = $this->action->__invoke($request, new Response());
$this->assertEquals(401, $response->getStatusCode());
}
示例8: it_should_return_406_response_if_no_best_format_found
public function it_should_return_406_response_if_no_best_format_found()
{
$this->formatNegotiator->getBestFormat(Argument::cetera())->willReturn(null);
$this->route->getOption(Argument::any())->shouldBeCalled();
$request = Request::create('/?format=json');
$this->__invoke($request)->shouldReturn406Response();
}
示例9: updateWizardDoesRunIfCssStyledContentIsNotInstalledAndExistingFlexFormContent
/**
* @test
* @return void
*/
public function updateWizardDoesRunIfCssStyledContentIsNotInstalledAndExistingFlexFormContent()
{
$this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(false);
$this->dbProphecy->exec_SELECTcountRows(Argument::cetera())->willReturn(1);
$description = '';
$this->assertTrue($this->updateWizard->checkForUpdate($description));
}
示例10: testWrites
/**
*
*/
public function testWrites()
{
$this->formatter->format(Argument::any())->shouldBeCalledTimes(1);
$this->writer->write(Argument::any(), Argument::any())->shouldBeCalledTimes(1);
$this->dumper->setEnabled(true);
$this->dumper->dump('id', ['test' => 1]);
}
示例11: testIsThrowingNonExistentFormException
/**
* @expectedException \Linio\DynamicFormBundle\Exception\FormlyMapperException
*/
public function testIsThrowingNonExistentFormException()
{
$formName = 'foo';
$this->formFactoryMock->getConfiguration($formName)->willThrow('Linio\\DynamicFormBundle\\Exception\\NonExistentFormException');
$this->formlyMapper->setFormFactory($this->formFactoryMock->reveal());
$this->formlyMapper->map($formName);
}
示例12: updateWizardDoesNotRunIfCssStyledContentIsInstalled
/**
* @test
* @return void
*/
public function updateWizardDoesNotRunIfCssStyledContentIsInstalled()
{
$this->packageManagerProphecy->isPackageActive('fluid_styled_content')->willReturn(true);
$this->packageManagerProphecy->isPackageActive('css_styled_content')->willReturn(true);
$description = '';
$this->assertFalse($this->updateWizard->checkForUpdate($description));
}
示例13: it_adds_entries_if_there_are_present_in_xml
/**
* @test
*/
public function it_adds_entries_if_there_are_present_in_xml()
{
$record = $this->prophesize(DTO\Record::class);
$this->mockedEntryDecoder->addTransactionDetails(Argument::type(DTO\Entry::class), Argument::type('\\SimpleXMLElement'))->shouldBeCalled();
$record->addEntry(Argument::type(DTO\Entry::class))->shouldBeCalled();
$this->decoder->addEntries($record->reveal(), $this->getXmlRecord());
}
示例14: it_should_set_route_option_if_controller_found
public function it_should_set_route_option_if_controller_found()
{
$request = Request::create('/');
$request->attributes->set('_controller', 'spec\\SDispatcher\\Middleware\\RouteOptionInspectorSpec');
$this->route->addOptions(Argument::any())->shouldBeCalled();
$this->__invoke($request);
}
示例15: translatePluralFallbacksToTranslator
/**
* @test
*/
public function translatePluralFallbacksToTranslator()
{
$this->translator->translatePlural('foo', 'bar', 'baz', 'default', null)->shouldBeCalledTimes(1);
$this->extension->translatePlural('foo', 'bar', 'baz');
$this->translator->translatePlural('foo', 'bar', 'baz', 'another', 'en')->shouldBeCalledTimes(1);
$this->extension->translatePlural('foo', 'bar', 'baz', 'another', 'en');
}