public resolve ( Nelmio\Alice\Definition\ValueInterface $value, Nelmio\Alice\FixtureInterface $fixture, |
||
$value | Nelmio\Alice\Definition\ValueInterface | |
$fixture | Nelmio\Alice\FixtureInterface | |
$fixtureSet | ||
$scope | array | |
$context | ||
return |
public function testThrowsAnExceptionIfResolvedReferenceHasNoSuchProperty() { try { $value = new FixturePropertyValue($reference = new FakeValue(), $property = 'prop'); $instance = new \stdClass(); $instance->prop = 'foo'; $set = ResolvedFixtureSetFactory::create(); $valueResolverProphecy = $this->prophesize(ValueResolverInterface::class); $valueResolverProphecy->resolve(Argument::cetera())->willReturn(new ResolvedValueWithFixtureSet(new \stdClass(), $set)); /** @var ValueResolverInterface $valueResolver */ $valueResolver = $valueResolverProphecy->reveal(); $resolver = new FixturePropertyReferenceResolver(PropertyAccess::createPropertyAccessor(), $valueResolver); $resolver->resolve($value, new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create()), $set, [], new GenerationContext()); $this->fail('Expected exception to be thrown.'); } catch (NoSuchPropertyException $exception) { $this->assertEquals('Could not find the property "prop" of the object "dummy" (class: Dummy).', $exception->getMessage()); $this->assertEquals(0, $exception->getCode()); $this->assertNotNull($exception->getPrevious()); } }