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


PHP ObjectProphecy::create方法代码示例

本文整理汇总了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());
 }
开发者ID:JahHub,项目名称:fertilizer,代码行数:9,代码来源:ObjectManagerTest.php

示例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));
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:8,代码来源:CachedDataboxRepositoryTest.php

示例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));
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:10,代码来源:DbalDataboxRepositoryTest.php

示例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);
     }
 }
开发者ID:J-Ben87,项目名称:ParsleyBundle,代码行数:21,代码来源:ConstraintBuilderTest.php

示例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);
 }
开发者ID:xurumelous,项目名称:dynamic-form-bundle,代码行数:18,代码来源:FormFactoryTest.php

示例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);
 }
开发者ID:JahHub,项目名称:fertilizer,代码行数:12,代码来源:AbstractEntityHandlerTest.php

示例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']);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:8,代码来源:GenerateKeyCommandTest.php


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