public function testThrowsExceptionIfCannotCreateInstance()
{
try {
$fixture = new DummyFixture('dummy');
$set = ResolvedFixtureSetFactory::create();
$decoratedInstantiatorProphecy = $this->prophesize(AbstractChainableInstantiator::class);
$decoratedInstantiatorProphecy->createInstance($fixture)->willThrow(\Error::class);
/** @var AbstractChainableInstantiator $decoratedInstantiator */
$decoratedInstantiator = $decoratedInstantiatorProphecy->reveal();
$instantiator = new ProphecyChainableInstantiator($decoratedInstantiator);
$instantiator->instantiate($fixture, $set, new GenerationContext());
$this->fail('Expected exception to be thrown.');
} catch (InstantiationException $exception) {
$this->assertEquals('Could not instantiate fixture "dummy".', $exception->getMessage());
$this->assertEquals(0, $exception->getCode());
$this->assertNotNull($exception->getPrevious());
}
}