Nelmio\Alice\Definition\SpecificationBagFactory::create PHP Метод

create() публичный статический Метод

public static create ( Nelmio\Alice\Definition\MethodCallInterface $constructor = null, PropertyBag $properties = null, MethodCallBag $calls = null ) : SpecificationBag
$constructor Nelmio\Alice\Definition\MethodCallInterface
$properties PropertyBag
$calls MethodCallBag
Результат SpecificationBag
    public static function create(MethodCallInterface $constructor = null, PropertyBag $properties = null, MethodCallBag $calls = null) : SpecificationBag
    {
        return new SpecificationBag($constructor, null === $properties ? new PropertyBag() : $properties, null === $calls ? new MethodCallBag() : $calls);
    }

Usage Example

Пример #1
0
 /**
  * @testdox Do a instantiate-hydrate-calls cycle to generate the object described by the fixture.
  */
 public function testGenerate()
 {
     $this->markTestIncomplete('TODO');
     $fixture = new SimpleFixture('dummy', \stdClass::class, SpecificationBagFactory::create());
     $set = ResolvedFixtureSetFactory::create();
     $context = new GenerationContext();
     $context->markIsResolvingFixture('foo');
     $instance = new \stdClass();
     $instantiatedObject = new SimpleObject($fixture->getId(), $instance);
     $instantiatorProphecy = $this->prophesize(InstantiatorInterface::class);
     $instantiatorProphecy->instantiate($fixture, $set, $context)->willReturn($setWithInstantiatedObject = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with($instantiatedObject)));
     /** @var InstantiatorInterface $instantiator */
     $instantiator = $instantiatorProphecy->reveal();
     $hydratedInstance = clone $instance;
     $hydratedInstance->hydrated = true;
     $hydratedObject = new SimpleObject($fixture->getId(), $hydratedInstance);
     $hydratorProphecy = $this->prophesize(HydratorInterface::class);
     $hydratorProphecy->hydrate($instantiatedObject, $setWithInstantiatedObject, $context)->willReturn($setWithHydratedObject = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with($hydratedObject)));
     /** @var HydratorInterface $hydrator */
     $hydrator = $hydratorProphecy->reveal();
     $instanceAfterCalls = clone $hydratedInstance;
     $instanceAfterCalls->calls = true;
     $objectAfterCalls = new SimpleObject($fixture->getId(), $instanceAfterCalls);
     $callerProphecy = $this->prophesize(CallerInterface::class);
     $callerProphecy->doCallsOn($hydratedObject, $setWithHydratedObject)->willReturn($setWithObjectAfterCalls = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with($objectAfterCalls)));
     /** @var CallerInterface $caller */
     $caller = $callerProphecy->reveal();
     $generator = new SimpleObjectGenerator(new FakeValueResolver(), $instantiator, $hydrator, $caller);
     $objects = $generator->generate($fixture, $set, $context);
     $this->assertEquals($setWithObjectAfterCalls->getObjects(), $objects);
     $instantiatorProphecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1);
     $hydratorProphecy->hydrate(Argument::cetera())->shouldHaveBeenCalledTimes(1);
     $callerProphecy->doCallsOn(Argument::cetera())->shouldHaveBeenCalledTimes(1);
 }
All Usage Examples Of Nelmio\Alice\Definition\SpecificationBagFactory::create
SpecificationBagFactory