getParameters() public method

public getParameters ( ) : ParameterBag
return Nelmio\Alice\ParameterBag
コード例 #1
0
 public function testResolvesAllArguments()
 {
     $specs = SpecificationBagFactory::create(new SimpleMethodCall('__construct', [$firstArg = new VariableValue('firstArg'), $secondArg = new VariableValue('secondArg')]));
     $resolvedSpecs = $specs->withConstructor(new SimpleMethodCall('__construct', ['resolvedFirstArg', 'resolvedSecondArg']));
     $fixture = new SimpleFixture('dummy', 'stdClass', $specs);
     $set = ResolvedFixtureSetFactory::create();
     $context = new GenerationContext();
     $context->markIsResolvingFixture('foo');
     $expected = ResolvedFixtureSetFactory::create(null, (new FixtureBag())->with($fixture->withSpecs($resolvedSpecs)), new ObjectBag(['dummy' => new \stdClass()]));
     $resolverProphecy = $this->prophesize(ValueResolverInterface::class);
     $setAfterFirstArgResolution = new ResolvedFixtureSet($set->getParameters(), (new FixtureBag())->with(new DummyFixture('dummy')), $set->getObjects());
     $resolverProphecy->resolve($firstArg, $fixture, $set, [], $context)->willReturn(new ResolvedValueWithFixtureSet('resolvedFirstArg', $setAfterFirstArgResolution));
     $setAfterSecondArgResolution = new ResolvedFixtureSet($setAfterFirstArgResolution->getParameters(), (new FixtureBag())->with(new DummyFixture('another_dummy')), $setAfterFirstArgResolution->getObjects());
     $resolverProphecy->resolve($secondArg, $fixture, $setAfterFirstArgResolution, [], $context)->willReturn(new ResolvedValueWithFixtureSet('resolvedSecondArg', $setAfterSecondArgResolution));
     /** @var ValueResolverInterface $resolver */
     $resolver = $resolverProphecy->reveal();
     $fixtureAfterResolution = $fixture->withSpecs($resolvedSpecs);
     $decoratedInstantiatorProphecy = $this->prophesize(InstantiatorInterface::class);
     $decoratedInstantiatorProphecy->instantiate($fixtureAfterResolution, $setAfterSecondArgResolution, $context)->willReturn($expected);
     /** @var InstantiatorInterface $decoratedInstantiator */
     $decoratedInstantiator = $decoratedInstantiatorProphecy->reveal();
     $instantiator = new InstantiatorResolver($decoratedInstantiator, $resolver);
     $actual = $instantiator->instantiate($fixture, $set, $context);
     $this->assertSame($expected, $actual);
     $resolverProphecy->resolve(Argument::cetera())->shouldHaveBeenCalledTimes(2);
     $decoratedInstantiatorProphecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  *
  * @param ParameterValue $value
  *
  * @throws UnresolvableValueException
  */
 public function resolve(ValueInterface $value, FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, array $scope, GenerationContext $context) : ResolvedValueWithFixtureSet
 {
     $parameterKey = $value->getValue();
     $parameters = $fixtureSet->getParameters();
     if (false === $parameters->has($parameterKey)) {
         throw UnresolvableValueExceptionFactory::createForCouldNotFindParameter($parameterKey);
     }
     return new ResolvedValueWithFixtureSet($parameters->get($parameterKey), $fixtureSet);
 }
コード例 #3
0
 public function testReadAccessorsReturnPropertiesValues()
 {
     $parameters = new ParameterBag();
     $fixtures = new FixtureBag();
     $objects = new ObjectBag();
     $set = new ResolvedFixtureSet($parameters, $fixtures, $objects);
     $this->assertEquals($parameters, $set->getParameters());
     $this->assertEquals($fixtures, $set->getFixtures());
     $this->assertEquals($objects, $set->getObjects());
 }