public function testIterateOverEveryInstantiatorAndUseTheFirstValidOne()
{
$fixture = new FakeFixture();
$set = ResolvedFixtureSetFactory::create();
$context = new GenerationContext();
$context->markIsResolvingFixture('foo');
$expected = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with(new SimpleObject('dummy', new \stdClass())));
$instantiator1Prophecy = $this->prophesize(ChainableInstantiatorInterface::class);
$instantiator1Prophecy->canInstantiate($fixture)->willReturn(false);
/* @var ChainableInstantiatorInterface $instantiator1 */
$instantiator1 = $instantiator1Prophecy->reveal();
$instantiator2Prophecy = $this->prophesize(ChainableInstantiatorInterface::class);
$instantiator2Prophecy->canInstantiate($fixture)->willReturn(true);
$instantiator2Prophecy->instantiate($fixture, $set, $context)->willReturn($expected);
/* @var ChainableInstantiatorInterface $instantiator2 */
$instantiator2 = $instantiator2Prophecy->reveal();
$instantiator3Prophecy = $this->prophesize(ChainableInstantiatorInterface::class);
$instantiator3Prophecy->canInstantiate(Argument::any())->shouldNotBeCalled();
/* @var ChainableInstantiatorInterface $instantiator3 */
$instantiator3 = $instantiator3Prophecy->reveal();
$registry = new InstantiatorRegistry([$instantiator1, $instantiator2, $instantiator3]);
$actual = $registry->instantiate($fixture, $set, $context);
$this->assertSame($expected, $actual);
$instantiator1Prophecy->canInstantiate(Argument::any())->shouldHaveBeenCalledTimes(1);
$instantiator2Prophecy->canInstantiate(Argument::any())->shouldHaveBeenCalledTimes(1);
$instantiator2Prophecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1);
}