Skip to content

Commit c5b4f35

Browse files
committed
Update to PHPUnit 6
1 parent 77579df commit c5b4f35

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"php": ">=7.0"
77
},
88
"require-dev": {
9-
"phpunit/phpunit": "^5.5"
9+
"phpunit/phpunit": "^6.4"
1010
},
1111
"license": "MIT",
1212
"authors": [

tests/LexicalGrammarTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@
55
*--------------------------------------------------------------------------------------------*/
66

77
use Microsoft\PhpParser\Token;
8+
use PHPUnit\Framework\Test;
89
use PHPUnit\Framework\TestCase;
10+
use PHPUnit\Framework\TestResult;
11+
use PHPUnit\Framework\BaseTestListener;
12+
use PHPUnit\Framework\AssertionFailedError;
913

1014
class LexicalGrammarTest extends TestCase {
1115
const FILE_PATTERN = __DIR__ . "/cases/lexical/*";
12-
public function run(PHPUnit_Framework_TestResult $result = null) : PHPUnit_Framework_TestResult {
16+
public function run(TestResult $result = null) : TestResult {
1317
if (!isset($GLOBALS["GIT_CHECKOUT_LEXER"])) {
1418
$GLOBALS["GIT_CHECKOUT_LEXER"] = true;
1519
exec("git -C " . dirname(self::FILE_PATTERN) . " checkout *.php.tokens");
1620
}
1721

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) {
2024
if (isset($test->expectedTokensFile) && isset($test->tokens)) {
2125
file_put_contents($test->expectedTokensFile, str_replace("\r\n", "\n", $test->tokens));
2226
}

tests/ParserGrammarTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@
66

77
use Microsoft\PhpParser\Token;
88
use Microsoft\PhpParser\DiagnosticsProvider;
9+
use PHPUnit\Framework\Test;
910
use PHPUnit\Framework\TestCase;
11+
use PHPUnit\Framework\TestResult;
12+
use PHPUnit\Framework\BaseTestListener;
13+
use PHPUnit\Framework\AssertionFailedError;
1014

1115
class ParserGrammarTest extends TestCase {
12-
public function run(PHPUnit_Framework_TestResult $result = null) : PHPUnit_Framework_TestResult {
16+
public function run(TestResult $result = null) : TestResult {
1317
if (!isset($GLOBALS["GIT_CHECKOUT_PARSER"])) {
1418
$GLOBALS["GIT_CHECKOUT_PARSER"] = true;
1519
exec("git -C " . dirname(self::FILE_PATTERN) . " checkout *.php.tree *.php.diag");
1620
}
1721

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) {
2024
if (isset($test->expectedTokensFile) && isset($test->tokens)) {
2125
file_put_contents($test->expectedTokensFile, str_replace("\r\n", "\n", $test->tokens));
2226
}
@@ -59,13 +63,13 @@ public function testOutputTreeClassificationAndLength($testCaseFile, $expectedTo
5963
$tokens = str_replace("\r\n", "\n", json_encode($sourceFileNode, JSON_PRETTY_PRINT));
6064
$diagnostics = str_replace("\r\n", "\n", json_encode(\Microsoft\PhpParser\DiagnosticsProvider::getDiagnostics($sourceFileNode), JSON_PRETTY_PRINT));
6165
$GLOBALS["SHORT_TOKEN_SERIALIZE"] = false;
62-
66+
6367
$this->tokens = $tokens;
6468
$this->diagnostics = $diagnostics;
6569

6670
$tokensOutputStr = "input doc:\r\n$fileContents\r\n\r\ninput: $testCaseFile\r\nexpected: $expectedTokensFile";
6771
$diagnosticsOutputStr = "input doc:\r\n$fileContents\r\n\r\ninput: $testCaseFile\r\nexpected: $expectedDiagnosticsFile";
68-
72+
6973
$this->assertEquals($expectedTokens, $tokens, $tokensOutputStr);
7074
$this->assertEquals($expectedDiagnostics, $diagnostics, $diagnosticsOutputStr);
7175
}

0 commit comments

Comments
 (0)