當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。