Nelmio\Alice\Parser\RuntimeCacheParserTest::testParsesTheResultAndCacheIt PHP Method

testParsesTheResultAndCacheIt() public method

    public function testParsesTheResultAndCacheIt()
    {
        $file1 = 'foo.php';
        $file2 = '/another/path/to/foo.php';
        $file3 = 'bar.yml';
        $fileLocatorProphecy = $this->prophesize(FileLocatorInterface::class);
        $fileLocatorProphecy->locate($file1)->willReturn('/path/to/foo.php');
        $fileLocatorProphecy->locate($file2)->willReturn('/path/to/foo.php');
        $fileLocatorProphecy->locate($file3)->willReturn('/path/to/bar.php');
        /** @var FileLocatorInterface $fileLocator */
        $fileLocator = $fileLocatorProphecy->reveal();
        $decoratedParserProphecy = $this->prophesize(ParserInterface::class);
        $decoratedParserProphecy->parse('/path/to/foo.php')->willReturn($file1Result = ['parameters' => ['foo']]);
        $decoratedParserProphecy->parse('/path/to/bar.php')->willReturn($file3Result = ['parameters' => ['bar']]);
        /* @var ParserInterface $decoratedParser */
        $decoratedParser = $decoratedParserProphecy->reveal();
        $includeProcessor = new FakeIncludeProcessor();
        $parser = new RuntimeCacheParser($decoratedParser, $fileLocator, $includeProcessor);
        $actual1 = $parser->parse($file1);
        $actual2 = $parser->parse($file2);
        $actual3 = $parser->parse($file3);
        $this->assertSame($file1Result, $actual1);
        $this->assertSame($file1Result, $actual2);
        $this->assertSame($file3Result, $actual3);
        $fileLocatorProphecy->locate(Argument::any())->shouldHaveBeenCalledTimes(3);
        $decoratedParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2);
    }