getId() public method

public getId ( ) : string
return string
Esempio n. 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);
 }
Esempio n. 2
0
 public function testReadAccessorsReturnPropertiesValues()
 {
     $reference = 'user0';
     $className = 'Nelmio\\Alice\\Entity\\User';
     $specs = SpecificationBagFactory::create();
     $fixture = new SimpleFixture($reference, $className, $specs);
     $this->assertEquals($reference, $fixture->getId());
     $this->assertEquals($className, $fixture->getClassName());
     $this->assertEquals($specs, $fixture->getSpecs());
     try {
         $fixture->getValueForCurrent();
         $this->fail('Expected exception to be thrown.');
     } catch (NoValueForCurrentException $exception) {
         $this->assertEquals('No value for \'<current()>\' found for the fixture "user0".', $exception->getMessage());
     }
     $fixture = new SimpleFixture($reference, $className, $specs, 'alice');
     $this->assertEquals($reference, $fixture->getId());
     $this->assertEquals($className, $fixture->getClassName());
     $this->assertEquals($specs, $fixture->getSpecs());
     $this->assertEquals('alice', $fixture->getValueForCurrent());
 }