Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / nikic / php-parser / test / PhpParser / ParserTest.php
index 9c4412dc19b29568ac82ac7bdd736af13c480efe..d31ac6efa4e47fe6f82b82403b7594f91a4eb2a5 100644 (file)
@@ -13,29 +13,23 @@ abstract class ParserTest extends TestCase
     /** @returns Parser */
     abstract protected function getParser(Lexer $lexer);
 
-    /**
-     * @expectedException \PhpParser\Error
-     * @expectedExceptionMessage Syntax error, unexpected EOF on line 1
-     */
     public function testParserThrowsSyntaxError() {
+        $this->expectException(Error::class);
+        $this->expectExceptionMessage('Syntax error, unexpected EOF on line 1');
         $parser = $this->getParser(new Lexer());
         $parser->parse('<?php foo');
     }
 
-    /**
-     * @expectedException \PhpParser\Error
-     * @expectedExceptionMessage Cannot use foo as self because 'self' is a special class name on line 1
-     */
     public function testParserThrowsSpecialError() {
+        $this->expectException(Error::class);
+        $this->expectExceptionMessage('Cannot use foo as self because \'self\' is a special class name on line 1');
         $parser = $this->getParser(new Lexer());
         $parser->parse('<?php use foo as self;');
     }
 
-    /**
-     * @expectedException \PhpParser\Error
-     * @expectedExceptionMessage Unterminated comment on line 1
-     */
     public function testParserThrowsLexerError() {
+        $this->expectException(Error::class);
+        $this->expectExceptionMessage('Unterminated comment on line 1');
         $parser = $this->getParser(new Lexer());
         $parser->parse('<?php /*');
     }
@@ -109,11 +103,9 @@ EOC;
         ], $var->getAttributes());
     }
 
-    /**
-     * @expectedException \RangeException
-     * @expectedExceptionMessage The lexer returned an invalid token (id=999, value=foobar)
-     */
     public function testInvalidToken() {
+        $this->expectException(\RangeException::class);
+        $this->expectExceptionMessage('The lexer returned an invalid token (id=999, value=foobar)');
         $lexer = new InvalidTokenLexer;
         $parser = $this->getParser($lexer);
         $parser->parse('dummy');
@@ -123,7 +115,7 @@ EOC;
      * @dataProvider provideTestExtraAttributes
      */
     public function testExtraAttributes($code, $expectedAttributes) {
-        $parser = $this->getParser(new Lexer);
+        $parser = $this->getParser(new Lexer\Emulative);
         $stmts = $parser->parse("<?php $code;");
         $node = $stmts[0] instanceof Stmt\Expression ? $stmts[0]->expr : $stmts[0];
         $attributes = $node->getAttributes();
@@ -152,17 +144,20 @@ EOC;
             ['"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]],
             ['b"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]],
             ['B"foo$bar"', ['kind' => String_::KIND_DOUBLE_QUOTED]],
-            ["<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
-            ["<<<STR\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
-            ["<<<\"STR\"\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
-            ["b<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
-            ["B<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
-            ["<<< \t 'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR']],
-            ["<<<'\xff'\n\xff\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => "\xff"]],
-            ["<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
-            ["b<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
-            ["B<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
-            ["<<< \t \"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR']],
+            ["<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["<<<STR\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["<<<\"STR\"\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["b<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["B<<<'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["<<< \t 'STR'\nSTR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["<<<'\xff'\n\xff\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => "\xff", 'docIndentation' => '']],
+            ["<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["b<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["B<<<\"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["<<< \t \"STR\"\n\$a\nSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '']],
+            ["<<<STR\n    STR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => '    ']],
+            ["<<<STR\n\tSTR\n", ['kind' => String_::KIND_HEREDOC, 'docLabel' => 'STR', 'docIndentation' => "\t"]],
+            ["<<<'STR'\n    Foo\n  STR\n", ['kind' => String_::KIND_NOWDOC, 'docLabel' => 'STR', 'docIndentation' => '  ']],
             ["die", ['kind' => Expr\Exit_::KIND_DIE]],
             ["die('done')", ['kind' => Expr\Exit_::KIND_DIE]],
             ["exit", ['kind' => Expr\Exit_::KIND_EXIT]],