本文整理汇总了PHP中Prophecy\Prophecy\ObjectProphecy::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectProphecy::create方法的具体用法?PHP ObjectProphecy::create怎么用?PHP ObjectProphecy::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prophecy\Prophecy\ObjectProphecy
的用法示例。
在下文中一共展示了ObjectProphecy::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreate
/**
*/
public function testCreate()
{
/** @var EntityInterface|ObjectProphecy $entity */
$entity = $this->prophesize('AppBundle\\Entity\\EntityInterface');
$this->repository->create()->willReturn($entity->reveal())->shouldBeCalledTimes(1);
$this->assertSame($entity->reveal(), $this->manager->create());
}
示例2: testItHydrateDataboxWhenInCache
public function testItHydrateDataboxWhenInCache()
{
$databox = $this->prophesize(\databox::class);
$this->cache->fetch($this->cacheKey)->willReturn([42 => ['foo' => 'bar']]);
$this->repository->find(42)->shouldNotBeCalled();
$this->factory->create(42, ['foo' => 'bar'])->willReturn($databox->reveal());
$this->assertSame($databox->reveal(), $this->sut->find(42));
}
示例3: testItReturnsNullOnNonExistentDatabox
public function testItReturnsNullOnNonExistentDatabox()
{
$statement = $this->prophesize(Statement::class);
$this->connection->prepare('SELECT ord, viewname, label_en, label_fr, label_de, label_nl FROM sbas WHERE sbas_id = :id')->willReturn($statement->reveal());
$statement->execute(['id' => 42])->shouldBeCalled();
$statement->fetch(\PDO::FETCH_ASSOC)->willReturn(false);
$statement->closeCursor()->shouldBeCalled();
$this->factory->create(42, Argument::any())->shouldNotBeCalled();
$this->assertNull($this->sut->find(42));
}
示例4: valid
/**
* @param array $symfonyConstraints
* @param array $expected
*
* @test
* @dataProvider validProvider
*/
public function valid(array $symfonyConstraints, array $expected)
{
foreach ($symfonyConstraints as $key => $constraint) {
$this->factory->create($constraint)->shouldBeCalled()->willReturn($expected[$key]);
}
$builder = $this->createBuilder();
$builder->configure(['constraints' => $symfonyConstraints]);
$parsleyConstraints = $builder->build();
$this->assertInternalType('array', $parsleyConstraints);
$this->assertCount(count($expected), $parsleyConstraints);
foreach ($parsleyConstraints as $key => $constraint) {
$this->assertSame($expected[$key], $constraint);
}
}
示例5: testIsCreatingFormWithTransformers
public function testIsCreatingFormWithTransformers()
{
$fieldOneMock = $this->prophesize('Symfony\\Component\\Form\\FormBuilder');
$formConfiguration = ['foo' => ['field1' => ['enabled' => true, 'type' => 'field1_type', 'transformer' => ['class' => 'Linio\\DynamicFormBundle\\Tests\\Form\\FormFactoryTest\\MockTransformer', 'calls' => [['setUserFormat', ['d/m/Y']], ['setInputFormat', ['Y-m-d']]]]]]];
$bornDateTransformer = new $formConfiguration['foo']['field1']['transformer']['class']();
$bornDateTransformer->setUserFormat(['d/m/Y']);
$bornDateTransformer->setInputFormat(['Y-m-d']);
$expectedFieldOptions = [];
$this->formFactoryMock->createNamedBuilder('foo', 'form', [], [])->willReturn($this->formBuilderMock->reveal());
$this->formBuilderMock->create('field1', 'field1_type', $expectedFieldOptions)->willReturn($fieldOneMock->reveal());
$fieldOneMock->addModelTransformer($bornDateTransformer)->shouldBeCalled();
$this->formBuilderMock->add($fieldOneMock->reveal())->shouldBeCalledTimes(1);
$this->formBuilderMock->getForm()->willReturn('foo_form');
$this->formFactory->setFormFactory($this->formFactoryMock->reveal());
$this->formFactory->setConfiguration($formConfiguration);
$actual = $this->formFactory->createForm('foo');
$this->assertEquals('foo_form', $actual);
}
示例6: prophesizeProcessFormFirstPart
/**
* @param string $formTypeName
* @param ObjectProphecy $entity
* @param string $method
* @param ObjectProphecy $form
* @param array $parameters
*/
protected function prophesizeProcessFormFirstPart($formTypeName, ObjectProphecy $entity, $method, ObjectProphecy $form, array $parameters)
{
$this->formFactory->create($formTypeName, $entity->reveal(), array('method' => $method))->willReturn($form->reveal())->shouldBeCalledTimes(1);
$form->submit($parameters, 'PATCH' !== $method)->shouldBeCalledTimes(1);
}
示例7: expirationDateIsDefinedIfWhenProvided
/**
* @test
*/
public function expirationDateIsDefinedIfWhenProvided()
{
$this->apiKeyService->create(Argument::type(\DateTime::class))->shouldBeCalledTimes(1);
$this->commandTester->execute(['command' => 'api-key:generate', '--expirationDate' => '2016-01-01']);
}