Nelmio\Alice\Parser\Chainable\YamlParserTest::testThrowsAnExceptionIfFileNotParsable PHP Method

testThrowsAnExceptionIfFileNotParsable() public method

    public function testThrowsAnExceptionIfFileNotParsable()
    {
        try {
            $file = self::$dir . '/basic.yml';
            $symfonyYamlParserProphecy = $this->prophesize(SymfonyYamlParser::class);
            $symfonyYamlParserProphecy->parse(Argument::any())->willThrow(SymfonyParseException::class);
            /* @var SymfonyYamlParser $symfonyYamlParser */
            $symfonyYamlParser = $symfonyYamlParserProphecy->reveal();
            $parser = new YamlParser($symfonyYamlParser);
            $parser->parse($file);
            $this->fail('Expected exception to be thrown.');
        } catch (UnparsableFileException $exception) {
            $this->assertRegExp('/^The file ".+\\/basic\\.yml" does not contain valid YAML\\.$/', $exception->getMessage());
            $this->assertEquals(0, $exception->getCode());
            $this->assertNotNull($exception->getPrevious());
        }
    }