parse() public method

public parse ( string $element ) : FlagBag
$element string
return Nelmio\Alice\Definition\FlagBag
Beispiel #1
0
 public function testIfAFlagIsFoundThenParsesItWithDecoratedParserBeforeReturningTheFlags()
 {
     $element = 'dummy ( flag1 , flag2 )';
     $decoratedParserProphecy = $this->prophesize(FlagParserInterface::class);
     $decoratedParserProphecy->parse('flag1')->willReturn((new FlagBag(''))->withFlag(new ElementFlag('flag1')));
     $decoratedParserProphecy->parse('flag2')->willReturn((new FlagBag(''))->withFlag(new ElementFlag('flag2'))->withFlag(new ElementFlag('additional flag')));
     /** @var FlagParserInterface $decoratedParser */
     $decoratedParser = $decoratedParserProphecy->reveal();
     $expected = (new FlagBag('dummy'))->withFlag(new ElementFlag('flag1'))->withFlag(new ElementFlag('flag2'))->withFlag(new ElementFlag('additional flag'));
     $parser = new ElementFlagParser($decoratedParser);
     $actual = $parser->parse($element);
     $this->assertEquals($expected, $actual);
 }