public function testPicksTheFirstSuitableParser()
{
$element = 'string to parse';
$expected = new FlagBag('');
$parser1Prophecy = $this->prophesize(ChainableFlagParserInterface::class);
$parser1Prophecy->canParse($element)->willReturn(false);
/** @var ChainableFlagParserInterface $parser1 */
$parser1 = $parser1Prophecy->reveal();
$parser2Prophecy = $this->prophesize(ChainableFlagParserInterface::class);
$parser2Prophecy->canParse($element)->willReturn(true);
$parser2Prophecy->parse($element)->willReturn($expected);
/** @var ChainableFlagParserInterface $parser2 */
$parser2 = $parser2Prophecy->reveal();
$parser3Prophecy = $this->prophesize(ChainableFlagParserInterface::class);
$parser3Prophecy->canParse(Argument::any())->shouldNotBeCalled();
/** @var ChainableFlagParserInterface $parser3 */
$parser3 = $parser3Prophecy->reveal();
$parser = new FlagParserRegistry([$parser1, $parser2, $parser3]);
$actual = $parser->parse($element);
$this->assertSame($expected, $actual);
$parser1Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1);
$parser2Prophecy->canParse(Argument::any())->shouldHaveBeenCalledTimes(1);
$parser2Prophecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1);
}