|
6 | 6 |
|
7 | 7 | use Microsoft\PhpParser\Token; |
8 | 8 | use Microsoft\PhpParser\DiagnosticsProvider; |
| 9 | +use PHPUnit\Framework\Test; |
9 | 10 | use PHPUnit\Framework\TestCase; |
| 11 | +use PHPUnit\Framework\TestResult; |
| 12 | +use PHPUnit\Framework\BaseTestListener; |
| 13 | +use PHPUnit\Framework\AssertionFailedError; |
10 | 14 |
|
11 | 15 | class ParserGrammarTest extends TestCase { |
12 | | - public function run(PHPUnit_Framework_TestResult $result = null) : PHPUnit_Framework_TestResult { |
| 16 | + public function run(TestResult $result = null) : TestResult { |
13 | 17 | if (!isset($GLOBALS["GIT_CHECKOUT_PARSER"])) { |
14 | 18 | $GLOBALS["GIT_CHECKOUT_PARSER"] = true; |
15 | 19 | exec("git -C " . dirname(self::FILE_PATTERN) . " checkout *.php.tree *.php.diag"); |
16 | 20 | } |
17 | 21 |
|
18 | | - $result->addListener(new class() extends PHPUnit_Framework_BaseTestListener { |
19 | | - function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) { |
| 22 | + $result->addListener(new class() extends BaseTestListener { |
| 23 | + function addFailure(Test $test, AssertionFailedError $e, $time) { |
20 | 24 | if (isset($test->expectedTokensFile) && isset($test->tokens)) { |
21 | 25 | file_put_contents($test->expectedTokensFile, str_replace("\r\n", "\n", $test->tokens)); |
22 | 26 | } |
@@ -59,13 +63,13 @@ public function testOutputTreeClassificationAndLength($testCaseFile, $expectedTo |
59 | 63 | $tokens = str_replace("\r\n", "\n", json_encode($sourceFileNode, JSON_PRETTY_PRINT)); |
60 | 64 | $diagnostics = str_replace("\r\n", "\n", json_encode(\Microsoft\PhpParser\DiagnosticsProvider::getDiagnostics($sourceFileNode), JSON_PRETTY_PRINT)); |
61 | 65 | $GLOBALS["SHORT_TOKEN_SERIALIZE"] = false; |
62 | | - |
| 66 | + |
63 | 67 | $this->tokens = $tokens; |
64 | 68 | $this->diagnostics = $diagnostics; |
65 | 69 |
|
66 | 70 | $tokensOutputStr = "input doc:\r\n$fileContents\r\n\r\ninput: $testCaseFile\r\nexpected: $expectedTokensFile"; |
67 | 71 | $diagnosticsOutputStr = "input doc:\r\n$fileContents\r\n\r\ninput: $testCaseFile\r\nexpected: $expectedDiagnosticsFile"; |
68 | | - |
| 72 | + |
69 | 73 | $this->assertEquals($expectedTokens, $tokens, $tokensOutputStr); |
70 | 74 | $this->assertEquals($expectedDiagnostics, $diagnostics, $diagnosticsOutputStr); |
71 | 75 | } |
|
0 commit comments