Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust tests to PHPUnit 10 #998

Merged
merged 13 commits into from
Jun 3, 2024
2 changes: 1 addition & 1 deletion test/PhpParser/Builder/ClassConstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function testValues($value, $expectedValueNode): void {
$this->assertEquals($expectedValueNode, $node->consts[0]->value);
}

public function provideTestDefaultValues() {
public static function provideTestDefaultValues() {
return [
[
null,
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Builder/EnumCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testValues($value, $expectedValueNode): void {
$this->assertEquals($expectedValueNode, $node->expr);
}

public function provideTestDefaultValues() {
public static function provideTestDefaultValues() {
return [
[
31415,
Expand Down
8 changes: 4 additions & 4 deletions test/PhpParser/Builder/ParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testDefaultValues($value, $expectedValueNode): void {
$this->assertEquals($expectedValueNode, $node->default);
}

public function provideTestDefaultValues() {
public static function provideTestDefaultValues() {
return [
[
null,
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testTypes($typeHint, $expectedType): void {
$this->assertEquals($expectedType, $type);
}

public function provideTestTypes() {
public static function provideTestTypes() {
return [
['array', new Node\Identifier('array')],
['callable', new Node\Identifier('callable')],
Expand All @@ -127,7 +127,7 @@ public function provideTestTypes() {
];
}

public function provideTestNullableTypes() {
public static function provideTestNullableTypes() {
return [
['?array', new Node\NullableType(new Node\Identifier('array'))],
['?Some\Class', new Node\NullableType(new Node\Name('Some\Class'))],
Expand All @@ -142,7 +142,7 @@ public function provideTestNullableTypes() {
];
}

public function provideTestUnionTypes() {
public static function provideTestUnionTypes() {
return [
[
new Node\UnionType([
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Builder/PropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function testAddAttribute(): void {
);
}

public function provideTestDefaultValues() {
public static function provideTestDefaultValues() {
return [
[
null,
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/BuilderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testFactory($methodName, $className): void {
$this->assertInstanceOf($className, $factory->$methodName('test'));
}

public function provideTestFactory() {
public static function provideTestFactory() {
return [
['namespace', Builder\Namespace_::class],
['class', Builder\Class_::class],
Expand Down
4 changes: 2 additions & 2 deletions test/PhpParser/CodeParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function getParseOutput(Parser $parser, $code, array $modes) {
return [$stmts, canonicalize($output)];
}

public function provideTestParse() {
return $this->getTests(__DIR__ . '/../code/parser', 'test');
public static function provideTestParse() {
return self::getTests(__DIR__ . '/../code/parser', 'test');
}

private function formatErrorMessage(Error $e, $code) {
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/CodeTestAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace PhpParser;

abstract class CodeTestAbstract extends \PHPUnit\Framework\TestCase {
protected function getTests($directory, $fileExtension, $chunksPerTest = 2) {
protected static function getTests($directory, $fileExtension, $chunksPerTest = 2) {
$parser = new CodeTestParser();
$allTests = [];
foreach (filesInDir($directory, $fileExtension) as $fileName => $fileContents) {
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testReformatting($commentText, $reformattedText): void {
$this->assertSame($reformattedText, $comment->getReformattedText());
}

public function provideTestReformatting() {
public static function provideTestReformatting() {
return [
['// Some text', '// Some text'],
['/* Some text */', '/* Some text */'],
Expand Down
4 changes: 2 additions & 2 deletions test/PhpParser/ConstExprEvaluatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testEvaluate($exprString, $expected): void {
$this->assertSame($expected, $evaluator->evaluateDirectly($expr));
}

public function provideTestEvaluate() {
public static function provideTestEvaluate() {
return [
['1', 1],
['1.0', 1.0],
Expand Down Expand Up @@ -115,7 +115,7 @@ public function testEvaluateSilently($expr, $exception, $msg): void {
}
}

public function provideTestEvaluateSilently() {
public static function provideTestEvaluateSilently() {
return [
[
new Expr\BinaryOp\Mod(new Scalar\Int_(42), new Scalar\Int_(0)),
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testColumnInfo($code, $startPos, $endPos, $startColumn, $endColu
$this->assertSame($endColumn, $error->getEndColumn($code));
}

public function provideTestColumnInfo() {
public static function provideTestColumnInfo() {
return [
// Error at "bar"
["<?php foo bar baz", 10, 12, 11, 13],
Expand Down
4 changes: 2 additions & 2 deletions test/PhpParser/Internal/DifferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testDiff($oldStr, $newStr, $expectedDiffStr): void {
$this->assertSame($expectedDiffStr, $this->formatDiffString($diff));
}

public function provideTestDiff() {
public static function provideTestDiff() {
return [
['abc', 'abc', 'abc'],
['abc', 'abcdef', 'abc+d+e+f'],
Expand All @@ -57,7 +57,7 @@ public function testDiffWithReplacements($oldStr, $newStr, $expectedDiffStr): vo
$this->assertSame($expectedDiffStr, $this->formatDiffString($diff));
}

public function provideTestDiffWithReplacements() {
public static function provideTestDiffWithReplacements() {
return [
['abcde', 'axyze', 'a/bx/cy/dze'],
['abcde', 'xbcdy', '/axbcd/ey'],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/JsonDecoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testDecodingError($json, $expectedMessage): void {
$jsonDecoder->decode($json);
}

public function provideTestDecodingError() {
public static function provideTestDecodingError() {
return [
['???', 'JSON decoding error: Syntax error'],
['{"nodeType":123}', 'Node type must be a string'],
Expand Down
6 changes: 3 additions & 3 deletions test/PhpParser/Lexer/EmulativeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testNoReplaceKeywordsAfterNullsafeObjectOperator(string $keyword
], $lexer->tokenize($code));
}

public function provideTestReplaceKeywords() {
public static function provideTestReplaceKeywords() {
return [
// PHP 8.0
['match', \T_MATCH],
Expand Down Expand Up @@ -173,7 +173,7 @@ public function testErrorAfterEmulation($code): void {
$this->assertSame($expLine, $attrs['endLine']);
}

public function provideTestLexNewFeatures() {
public static function provideTestLexNewFeatures() {
return [
['yield from', [
[\T_YIELD_FROM, 'yield from'],
Expand Down Expand Up @@ -401,7 +401,7 @@ public function testTargetVersion(string $phpVersion, string $code, array $expec
$this->assertSameTokens($expectedTokens, $lexer->tokenize('<?php ' . $code));
}

public function provideTestTargetVersion() {
public static function provideTestTargetVersion() {
return [
['8.0', 'match', [[\T_MATCH, 'match']]],
['7.4', 'match', [[\T_STRING, 'match']]],
Expand Down
4 changes: 2 additions & 2 deletions test/PhpParser/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testError($code, $messages): void {
}
}

public function provideTestError() {
public static function provideTestError() {
return [
["<?php /*", ["Unterminated comment from 1:7 to 1:9"]],
["<?php /*\n", ["Unterminated comment from 1:7 to 2:1"]],
Expand Down Expand Up @@ -70,7 +70,7 @@ public function testLex($code, $expectedTokens): void {
}
}

public function provideTestLex() {
public static function provideTestLex() {
return [
// tests PHP 8 T_NAME_* emulation
[
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/NameContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testGetPossibleNames($type, $name, $expectedPossibleNames): void
);
}

public function provideTestGetPossibleNames() {
public static function provideTestGetPossibleNames() {
return [
[Use_::TYPE_NORMAL, 'Test', ['\Test']],
[Use_::TYPE_NORMAL, 'Test\Namespaced', ['\Test\Namespaced']],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/Expr/CallableLikeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function testIsFirstClassCallable(CallLike $node, bool $isFirstClassCalla
}
}

public function provideTestIsFirstClassCallable() {
public static function provideTestIsFirstClassCallable() {
$normalArgs = [new Arg(new Int_(1))];
$callableArgs = [new VariadicPlaceholder()];
return [
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/IdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testIsSpecialClassName($identifier, $expected): void {
$this->assertSame($expected, $identifier->isSpecialClassName());
}

public function provideTestIsSpecialClassName() {
public static function provideTestIsSpecialClassName() {
return [
['self', true],
['PARENT', true],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function testIsSpecialClassName($name, $expected): void {
$this->assertSame($expected, $name->isSpecialClassName());
}

public function provideTestIsSpecialClassName() {
public static function provideTestIsSpecialClassName() {
return [
['self', true],
['PARENT', true],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/ParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testModifiers(string $modifier): void {
$this->assertTrue($node->{'is' . $modifier}());
}

public function provideModifiers() {
public static function provideModifiers() {
return [
['public'],
['protected'],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/Scalar/MagicConstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function testGetName(MagicConst $magicConst, $name): void {
$this->assertSame($name, $magicConst->getName());
}

public function provideTestGetName() {
public static function provideTestGetName() {
return [
[new MagicConst\Class_(), '__CLASS__'],
[new MagicConst\Dir(), '__DIR__'],
Expand Down
6 changes: 3 additions & 3 deletions test/PhpParser/Node/Scalar/StringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testCreate($expected, $string): void {
);
}

public function provideTestParseEscapeSequences() {
public static function provideTestParseEscapeSequences() {
return [
['"', '\\"', '"'],
['\\"', '\\"', '`'],
Expand All @@ -57,7 +57,7 @@ public function provideTestParseEscapeSequences() {
];
}

public function provideTestParse() {
public static function provideTestParse() {
$tests = [
['A', '\'A\''],
['A', 'b\'A\''],
Expand All @@ -67,7 +67,7 @@ public function provideTestParse() {
['\'', '\'\\\'\''],
];

foreach ($this->provideTestParseEscapeSequences() as $i => $test) {
foreach (self::provideTestParseEscapeSequences() as $i => $test) {
// skip second and third tests, they aren't for double quotes
if ($i !== 1 && $i !== 2) {
$tests[] = [$test[0], '"' . $test[1] . '"'];
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/Stmt/ClassConstTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testNoModifiers(): void {
$this->assertFalse($node->isFinal());
}

public function provideModifiers() {
public static function provideModifiers() {
return [
['public'],
['protected'],
Expand Down
6 changes: 3 additions & 3 deletions test/PhpParser/Node/Stmt/ClassMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testNoModifiers(): void {
$this->assertFalse($node->isMagic());
}

public function provideModifiers() {
public static function provideModifiers() {
return [
['public'],
['protected'],
Expand All @@ -57,7 +57,7 @@ public function testImplicitPublic(string $modifier): void {
$this->assertTrue($node->isPublic(), 'Node should be implicitly public');
}

public function implicitPublicModifiers() {
public static function implicitPublicModifiers() {
return [
['abstract'],
['final'],
Expand All @@ -75,7 +75,7 @@ public function testMagic(string $name): void {
$this->assertTrue($node->isMagic(), 'Method should be magic');
}

public function provideMagics() {
public static function provideMagics() {
return [
['__construct'],
['__DESTRUCT'],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/Node/Stmt/PropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testStaticImplicitlyPublic(): void {
$this->assertFalse($node->isReadonly());
}

public function provideModifiers() {
public static function provideModifiers() {
return [
['public'],
['protected'],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/NodeAbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getType(): string {
}

class NodeAbstractTest extends \PHPUnit\Framework\TestCase {
public function provideNodes() {
public static function provideNodes() {
$attributes = [
'startLine' => 10,
'endLine' => 11,
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/NodeDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function testDump($node, $dump): void {
$this->assertSame($this->canonicalize($dump), $this->canonicalize($dumper->dump($node)));
}

public function provideTestDump() {
public static function provideTestDump() {
return [
[
[],
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/NodeTraverserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ public function testInvalidReturn($stmts, $visitor, $message): void {
$traverser->traverse($stmts);
}

public function provideTestInvalidReturn() {
public static function provideTestInvalidReturn() {
$num = new Node\Scalar\Int_(42);
$expr = new Node\Stmt\Expression($num);
$stmts = [$expr];
Expand Down
2 changes: 1 addition & 1 deletion test/PhpParser/NodeVisitor/NameResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function testError(Node $stmt, $errorMsg): void {
$traverser->traverse([$stmt]);
}

public function provideTestError() {
public static function provideTestError() {
return [
[
new Stmt\Use_([
Expand Down
4 changes: 2 additions & 2 deletions test/PhpParser/Parser/Php7Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace PhpParser\Parser;

use PhpParser\Lexer;
use PhpParser\ParserTest;
use PhpParser\ParserTestAbstract;

class Php7Test extends ParserTest
class Php7Test extends ParserTestAbstract
{
protected function getParser(Lexer $lexer) {
return new Php7($lexer);
Expand Down
4 changes: 2 additions & 2 deletions test/PhpParser/Parser/Php8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace PhpParser\Parser;

use PhpParser\Lexer;
use PhpParser\ParserTest;
use PhpParser\ParserTestAbstract;

class Php8Test extends ParserTest
class Php8Test extends ParserTestAbstract
{
protected function getParser(Lexer $lexer) {
return new Php8($lexer);
Expand Down
Loading