本文整理匯總了PHP中Prophecy\Prophet::checkPredictions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Prophet::checkPredictions方法的具體用法?PHP Prophet::checkPredictions怎麽用?PHP Prophet::checkPredictions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Prophecy\Prophet
的用法示例。
在下文中一共展示了Prophet::checkPredictions方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tearDown
protected function tearDown()
{
if ($this->prophet) {
$this->prophet->checkPredictions();
}
parent::tearDown();
}
示例2: Prophet
function it_should_be_able_to_run_processes()
{
$prophet = new Prophet();
$processes = [];
for ($i = 0; $i < 20; $i++) {
$process = $prophet->prophesize(Process::class);
$process->started = false;
$process->terminated = false;
$process->start()->will(function () use($process) {
$process->started = true;
})->shouldBeCalledTimes(1);
$process->isTerminated()->will(function () use($process) {
if (!$process->terminated) {
$process->terminated = true;
return false;
}
return true;
})->shouldBeCalledTimes(2);
// The number of times isStarted() is called starts at 3
// and increases by 2 after each chunk of five processes.
$process->isStarted()->will(function () use($process) {
return $process->started;
})->shouldBeCalledTimes(floor($i / 5) * 2 + 3);
$processes[] = $process->reveal();
}
$this->run($processes);
$prophet->checkPredictions();
}
示例3: verifyMockObjects
protected function verifyMockObjects()
{
parent::verifyMockObjects();
if (null === $this->prophet) {
return;
}
try {
$this->prophet->checkPredictions();
} catch (\Exception $e) {
/** Intentionally left empty */
}
$this->countProphecyAssertions();
if (isset($e)) {
throw $e;
}
}
示例4: expectingWithoutOptionalParameter
/**
* Calling no optional parameter
*
* @test
* @see https://github.com/php-mock/php-mock-prophecy/issues/1
*/
public function expectingWithoutOptionalParameter()
{
$prophet = new Prophet();
$prophecy = $prophet->prophesize(OptionalParameterHolder::class);
$prophecy->call("arg1")->willReturn("mocked");
$mock = $prophecy->reveal();
$this->assertEquals("mocked", $mock->call("arg1"));
$prophet->checkPredictions();
}
示例5: verifyMockObjects
/**
* {@inheritdoc}
*/
protected function verifyMockObjects()
{
parent::verifyMockObjects();
if ($this->prophet !== null) {
try {
$this->prophet->checkPredictions();
} catch (\Exception $e) {
/** Intentionally left empty */
}
foreach ($this->prophet->getProphecies() as $objectProphecy) {
foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) {
foreach ($methodProphecies as $methodProphecy) {
$this->addToAssertionCount(count($methodProphecy->getCheckedPredictions()));
}
}
}
if (isset($e)) {
throw $e;
}
}
}
示例6: testOnNewAccountCreated
public function testOnNewAccountCreated()
{
$userName = 'tester';
$userEmail = 'tester@example.com';
$messageBody = 'Body';
$messageSubject = 'Subject';
$template = $this->prophet->prophesize('Twig_Template');
$event = $this->prophet->prophesize('Smoovio\\Bundle\\CoreBundle\\Event\\NewAccountCreatedEvent');
$user = $this->prophet->prophesize('Smoovio\\Bundle\\CoreBundle\\Entity\\User');
$this->templating->loadTemplate($this->templateName)->willReturn($template->reveal())->shouldBeCalled();
$template->renderBlock('subject', [])->willReturn('Subject');
$event->getUser()->willReturn($user);
$user->getUsername()->willReturn($userName);
$user->getEmail()->willReturn($userEmail);
$template->renderBlock('body', ['username' => $userName])->willReturn($messageBody)->shouldBeCalled();
$this->mailer->send(Argument::that(function (\Swift_Message $message) use($userEmail, $messageBody, $messageSubject) {
$this->assertSame($this->sender, $message->getSender());
$this->assertSame($userEmail, $message->getTo());
$this->assertSame($messageSubject, $message->getSubject());
$this->assertSame($messageBody, $message->getBody());
}));
$this->listener->onNewAccountCreated($event->reveal());
$this->prophet->checkPredictions();
}
示例7: testManagerCreatesUserSuccessfulWithProphecy
public function testManagerCreatesUserSuccessfulWithProphecy()
{
$prophet = new Prophet();
$manager = $prophet->prophesize('Doctrine\\Common\\Persistence\\ObjectManager');
$encoderFactory = $prophet->prophesize('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface');
$encoder = $prophet->prophesize('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface');
$dispatcher = $prophet->prophesize('Symfony\\Component\\Eventdispatcher\\EventDispatcherInterface');
$user = $prophet->prophesize('Smoovio\\Bundle\\CoreBundle\\Entity\\User');
$encoderFactory->getEncoder($user->reveal())->willReturn($encoder)->shouldBeCalled();
$user->encodePassword($encoder->reveal())->shouldBeCalled();
$manager->persist($user)->shouldBeCalled();
$manager->flush()->shouldBeCalled();
$dispatcher->dispatch(CoreEvents::NEW_ACCOUNT_CREATED, Argument::that(function ($event) use($user) {
return $event instanceof NewAccountCreatedEvent && $event->getUser() === $user;
}));
$userManager = new UserManager($manager->reveal(), $encoderFactory->reveal(), $dispatcher->reveal());
$userManager->createUser($user->reveal());
$prophet->checkPredictions();
}
示例8: array
function it_should_return_messages_to_given_recipient(ConnectionInterface $connection, ArrayToMessageTransformer $messageTransformer)
{
$rawMessages = array(array('id' => 4, 'recipients' => array('john.doe@example.com')), array('id' => 2, 'recipients' => array('demo@example.com', 'john.doe@example.com')), array('id' => 1, 'recipients' => array('john@example.com')));
$prophet = new Prophet();
$mockMessages = array($prophet->prophesize('Kibao\\MailCatcher\\Message\\MessageInterface'), $prophet->prophesize('Kibao\\MailCatcher\\Message\\MessageInterface'), $prophet->prophesize('Kibao\\MailCatcher\\Message\\MessageInterface'));
for ($i = 0; $i < 3; $i++) {
$rawMessage = $rawMessages[$i];
$recipients = array();
foreach ($rawMessage['recipients'] as $email) {
$recipient = $prophet->prophesize('Kibao\\MailCatcher\\Address\\AddressInterface');
$recipient->getEmail()->willReturn($email);
$recipients[] = $recipient;
}
$mockMessages[$i]->getRecipients()->willReturn($recipients);
$messageTransformer->transform($rawMessage)->willReturn($mockMessages[$i]);
$connection->getMessage($rawMessage['id'])->willReturn($rawMessage);
}
$connection->getMessages()->willReturn($rawMessages);
$this->getMessagesTo('john.doe@example.com')->shouldReturn(array($mockMessages[0], $mockMessages[1]));
$prophet->checkPredictions();
}
示例9: verifyMockObjects
/**
* Verifies the mock object expectations.
*
* @since Method available since Release 3.5.0
*/
protected function verifyMockObjects()
{
foreach ($this->mockObjects as $mockObject) {
if ($mockObject->__phpunit_hasMatchers()) {
$this->numAssertions++;
}
$mockObject->__phpunit_verify();
}
if ($this->prophet !== null) {
try {
$this->prophet->checkPredictions();
} catch (Exception $e) {
/** Intentionally left empty */
}
foreach ($this->prophet->getProphecies() as $objectProphecy) {
foreach ($objectProphecy->getMethodProphecies() as $methodProphecies) {
foreach ($methodProphecies as $methodProphecy) {
$this->numAssertions += count($methodProphecy->getCheckedPredictions());
}
}
}
if (isset($e)) {
throw $e;
}
}
}
示例10: tearDown
public function tearDown()
{
$this->prophet->checkPredictions();
}
示例11: teardown
/**
* @param ExampleNode $example
* @param SpecificationInterface $context
* @param MatcherManager $matchers
* @param CollaboratorManager $collaborators
*/
public function teardown(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators)
{
$this->prophet->checkPredictions();
}
示例12: letgo
public function letgo()
{
$this->prophet->checkPredictions();
}
示例13: tearDown
protected function tearDown()
{
$prophet = new Prophet();
$prophet->checkPredictions();
}
示例14: tearDown
/**
* {@inheridoc}.
*/
protected function tearDown()
{
$this->prophet->checkPredictions();
}
示例15: assertPostConditions
protected function assertPostConditions()
{
if ($this->prophet) {
$this->prophet->checkPredictions();
}
}