Inheritance: implements Nelmio\Alice\FixtureBuilder\ExpressionLanguage\ParserInterface, use trait Nelmio\Alice\IsAServiceTrait
Beispiel #1
0
 public function testIfATokenIsParsedIntoANestedValueThenItsValuesAreMerged()
 {
     $value = 'foo';
     $lexerProphecy = $this->prophesize(LexerInterface::class);
     $lexerProphecy->lex($value)->willReturn([$token1 = new Token('foo', new TokenType(TokenType::STRING_TYPE)), $token2 = new Token('bar', new TokenType(TokenType::VARIABLE_TYPE)), $token3 = new Token('baz', new TokenType(TokenType::FUNCTION_TYPE))]);
     /** @var LexerInterface $lexer */
     $lexer = $lexerProphecy->reveal();
     $tokenParserProphecy = $this->prophesize(TokenParserInterface::class);
     $tokenParserProphecy->parse($token1)->willReturn('parsed_foo');
     $tokenParserProphecy->parse($token2)->willReturn(new NestedValue(['first', 'second']));
     $tokenParserProphecy->parse($token3)->willReturn('parsed_baz');
     /** @var TokenParserInterface $tokenParser */
     $tokenParser = $tokenParserProphecy->reveal();
     $expected = new ListValue(['parsed_foo', 'first', 'second', 'parsed_baz']);
     $parser = new SimpleParser($lexer, $tokenParser);
     $actual = $parser->parse($value);
     $this->assertEquals($expected, $actual);
     $lexerProphecy->lex(Argument::any())->shouldHaveBeenCalledTimes(1);
     $tokenParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(3);
 }