diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cda1f4fc7..f50c1b293 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ - + src + + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 34fd1648c..c424a77e6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + partitions]]> @@ -1481,6 +1481,11 @@ tokens]]> + + + provideBuilderForRenameColumn + + fields]]> @@ -1498,8 +1503,19 @@ isEmpty isEmpty + + partitionQueriesProvider + + + + + getAliasesProvider + + + parseProvider + $components $components @@ -1564,6 +1580,15 @@ table]]> table]]> + + mysqlCommandsProvider + parseErrProvider + + + + + provideExpressions + @@ -1578,7 +1603,15 @@ assertNull + + + parseProvider + + + + parseErrProvider + assertNotNull assertNotNull @@ -1595,10 +1628,85 @@ $component + + + contextLoadingProvider + contextNamesProvider + providerForTestMode + + + + + lexProvider + + + + + bugProvider + + + + + parameterProvider + + + + + utf8StringsProvider + + + + + alterProvider + + + + + analyzeProvider + + + + + callProvider + + + + + createProvider + + + + + deleteProvider + + + + + dropProvider + + + + + explainProvider + + + + + insertProvider + + has + + loadProvider + + + + + lockProvider + @@ -1607,11 +1715,62 @@ statements]]> + + exportFileProvider + + + + + parseProvider + + + + + purgeProvider + + + + + renameProvider + + + + + replaceProvider + + + + + restoreProvider + has + + selectProvider + + + + + setProvider + + + + + transactionProvider + + + + + updateProvider + + + + + parseWith + @@ -1635,7 +1794,27 @@ TestContext + + + extractProvider + + + + + highlightParamsProvider + highlightParamsStdInProvider + lintParamsProvider + lintParamsStdInProvider + stdinParamsProvider + tokenizeParamsProvider + tokenizeParamsStdInProvider + + + + formatQueriesProviders + mergeFormatsProvider + setAccessible @@ -1659,6 +1838,10 @@ list]]> list]]> + + getFlagsProvider + getTablesProvider + $delimiter $delimiter @@ -1669,6 +1852,11 @@ statements[0]]]> + + getParameterProvider + getParametersProvider + getReturnTypeProvider + @@ -1777,11 +1965,19 @@ * expr?: string * }>}>]]> + + getFieldsProvider + getForeignKeysProvider + $find + + matchProvider + replaceTokensProvider + diff --git a/tests/Builder/AlterStatementTest.php b/tests/Builder/AlterStatementTest.php index 4dcaf96f1..79472c9b8 100644 --- a/tests/Builder/AlterStatementTest.php +++ b/tests/Builder/AlterStatementTest.php @@ -7,6 +7,7 @@ use Generator; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AlterStatementTest extends TestCase { @@ -184,9 +185,7 @@ public static function provideBuilderForRenameColumn(): Generator yield 'Mixed RENAME table + RENAME INDEX + RENAME COLUMNS' => [$query]; } - /** - * @dataProvider provideBuilderForRenameColumn - */ + #[DataProvider('provideBuilderForRenameColumn')] public function testBuilderRenameColumn(string $query): void { $parser = new Parser($query); diff --git a/tests/Builder/CreateStatementTest.php b/tests/Builder/CreateStatementTest.php index 95f24d751..9feef91cf 100644 --- a/tests/Builder/CreateStatementTest.php +++ b/tests/Builder/CreateStatementTest.php @@ -14,6 +14,7 @@ use PhpMyAdmin\SqlParser\Statements\CreateStatement; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\TokensList; +use PHPUnit\Framework\Attributes\DataProvider; class CreateStatementTest extends TestCase { @@ -299,9 +300,7 @@ public static function partitionQueriesProvider(): array ]; } - /** - * @dataProvider partitionQueriesProvider - */ + #[DataProvider('partitionQueriesProvider')] public function testBuilderPartitionsEngine(string $query): void { $parser = new Parser($query); diff --git a/tests/Builder/StatementTest.php b/tests/Builder/StatementTest.php index 01a127c46..14339e185 100644 --- a/tests/Builder/StatementTest.php +++ b/tests/Builder/StatementTest.php @@ -11,6 +11,7 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Statements\SelectStatement; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class StatementTest extends TestCase { @@ -46,9 +47,8 @@ public function testBuilder(): void * alias: (string|null), * tables: array}> * }> $expected - * - * @dataProvider getAliasesProvider */ + #[DataProvider('getAliasesProvider')] public function testGetAliases(string $query, string $db, array $expected): void { $parser = new Parser($query); diff --git a/tests/Components/ArrayObjTest.php b/tests/Components/ArrayObjTest.php index 5a2515409..a1e12e87f 100644 --- a/tests/Components/ArrayObjTest.php +++ b/tests/Components/ArrayObjTest.php @@ -8,6 +8,7 @@ use PhpMyAdmin\SqlParser\Components\Expression; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ArrayObjTest extends TestCase { @@ -39,9 +40,7 @@ public function testParseType(): void $this->assertEquals($components[1]->expr, '3 + 4'); } - /** - * @dataProvider parseProvider - */ + #[DataProvider('parseProvider')] public function testParse(string $test): void { $this->runParserTest($test); diff --git a/tests/Components/ExpressionTest.php b/tests/Components/ExpressionTest.php index 73dfe7cd2..29fa2764d 100644 --- a/tests/Components/ExpressionTest.php +++ b/tests/Components/ExpressionTest.php @@ -7,6 +7,7 @@ use PhpMyAdmin\SqlParser\Components\Expression; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ExpressionTest extends TestCase { @@ -39,9 +40,7 @@ public function testParse3(): void $this->assertEquals($component->expr, 'x.id'); } - /** - * @dataProvider parseErrProvider - */ + #[DataProvider('parseErrProvider')] public function testParseErr(string $expr, string $error): void { $parser = new Parser(); @@ -142,9 +141,7 @@ public static function mysqlCommandsProvider(): array ]; } - /** - * @dataProvider mysqlCommandsProvider - */ + #[DataProvider('mysqlCommandsProvider')] public function testMysqlCommands(string $expr, string $expected): void { $parser = new Parser($expr, true); diff --git a/tests/Components/GroupKeywordTest.php b/tests/Components/GroupKeywordTest.php index 4ddba7789..0f74af6d3 100644 --- a/tests/Components/GroupKeywordTest.php +++ b/tests/Components/GroupKeywordTest.php @@ -8,6 +8,7 @@ use PhpMyAdmin\SqlParser\Components\Expression; use PhpMyAdmin\SqlParser\Components\GroupKeyword; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use function array_map; @@ -53,9 +54,8 @@ public static function provideExpressions(): Generator /** * @param GroupKeyword|array $component - * - * @dataProvider provideExpressions */ + #[DataProvider('provideExpressions')] public function testBuild($component, string $expected): void { $this->assertSame($expected, GroupKeyword::build($component)); diff --git a/tests/Components/LimitTest.php b/tests/Components/LimitTest.php index e8c29048c..5f35c7710 100644 --- a/tests/Components/LimitTest.php +++ b/tests/Components/LimitTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Components\Limit; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class LimitTest extends TestCase { @@ -21,9 +22,7 @@ public function testBuildWithOffset(): void $this->assertEquals(Limit::build($component), '2, 1'); } - /** - * @dataProvider parseProvider - */ + #[DataProvider('parseProvider')] public function testParse(string $test): void { $this->runParserTest($test); diff --git a/tests/Components/LockExpressionTest.php b/tests/Components/LockExpressionTest.php index e1cb4919e..be15cde87 100644 --- a/tests/Components/LockExpressionTest.php +++ b/tests/Components/LockExpressionTest.php @@ -7,6 +7,7 @@ use PhpMyAdmin\SqlParser\Components\LockExpression; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class LockExpressionTest extends TestCase { @@ -27,9 +28,7 @@ public function testParse2(): void $this->assertEquals($component->type, 'LOW_PRIORITY WRITE'); } - /** - * @dataProvider parseErrProvider - */ + #[DataProvider('parseErrProvider')] public function testParseErr(string $expr, string $error): void { $parser = new Parser(); diff --git a/tests/Lexer/ContextTest.php b/tests/Lexer/ContextTest.php index 76e79a364..64887816f 100644 --- a/tests/Lexer/ContextTest.php +++ b/tests/Lexer/ContextTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; use function class_exists; @@ -27,9 +28,8 @@ public function testLoad(): void /** * Test for loading closest SQL context - * - * @dataProvider contextLoadingProvider */ + #[DataProvider('contextLoadingProvider')] public function testLoadClosest(string $context, string|null $expected): void { $this->assertEquals($expected, Context::loadClosest($context)); @@ -80,9 +80,7 @@ public static function contextLoadingProvider(): array ]; } - /** - * @dataProvider contextNamesProvider - */ + #[DataProvider('contextNamesProvider')] public function testLoadAll(string $context): void { Context::load($context); @@ -118,9 +116,8 @@ public function testLoadError(): void /** * @param int|string $mode - * - * @dataProvider providerForTestMode */ + #[DataProvider('providerForTestMode')] public function testMode($mode, int $expected): void { Context::setMode($mode); diff --git a/tests/Lexer/LexerTest.php b/tests/Lexer/LexerTest.php index abee44f36..a99654567 100644 --- a/tests/Lexer/LexerTest.php +++ b/tests/Lexer/LexerTest.php @@ -7,15 +7,16 @@ use PhpMyAdmin\SqlParser\Exceptions\LexerException; use PhpMyAdmin\SqlParser\Lexer; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use function sprintf; class LexerTest extends TestCase { - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[RunInSeparateProcess] + #[PreserveGlobalState(false)] public function testError(): void { $lexer = new Lexer(''); @@ -48,9 +49,7 @@ public function testErrorStrict(): void $lexer->error('strict error', 'foo', 1, 4); } - /** - * @dataProvider lexProvider - */ + #[DataProvider('lexProvider')] public function testLex(string $test): void { $this->runParserTest($test); diff --git a/tests/Misc/BugsTest.php b/tests/Misc/BugsTest.php index 482944547..bc3a50e09 100644 --- a/tests/Misc/BugsTest.php +++ b/tests/Misc/BugsTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Misc; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class BugsTest extends TestCase { - /** - * @dataProvider bugProvider - */ + #[DataProvider('bugProvider')] public function testBug(string $test): void { $this->runParserTest($test); diff --git a/tests/Misc/ParameterTest.php b/tests/Misc/ParameterTest.php index 08c4c5031..22e0d668b 100644 --- a/tests/Misc/ParameterTest.php +++ b/tests/Misc/ParameterTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Misc; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ParameterTest extends TestCase { - /** - * @dataProvider parameterProvider - */ + #[DataProvider('parameterProvider')] public function testParameter(string $test): void { $this->runParserTest($test); diff --git a/tests/Misc/UtfStringTest.php b/tests/Misc/UtfStringTest.php index 8d03b6cf3..5cc5a4a18 100644 --- a/tests/Misc/UtfStringTest.php +++ b/tests/Misc/UtfStringTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\UtfString; +use PHPUnit\Framework\Attributes\DataProvider; use Throwable; use function chr; @@ -83,9 +84,8 @@ public function testToString(): void /** * Test access to string. - * - * @dataProvider utf8StringsProvider */ + #[DataProvider('utf8StringsProvider')] public function testAccess(string $text, string|null $pos10, string|null $pos20): void { $str = new UtfString($text); diff --git a/tests/Parser/AlterStatementTest.php b/tests/Parser/AlterStatementTest.php index 0f958a161..7659bd7b6 100644 --- a/tests/Parser/AlterStatementTest.php +++ b/tests/Parser/AlterStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AlterStatementTest extends TestCase { - /** - * @dataProvider alterProvider - */ + #[DataProvider('alterProvider')] public function testAlter(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/AnalyzeStatementTest.php b/tests/Parser/AnalyzeStatementTest.php index 9c8543a6c..d9935ac1a 100644 --- a/tests/Parser/AnalyzeStatementTest.php +++ b/tests/Parser/AnalyzeStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class AnalyzeStatementTest extends TestCase { - /** - * @dataProvider analyzeProvider - */ + #[DataProvider('analyzeProvider')] public function testAnalyze(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/CallStatementTest.php b/tests/Parser/CallStatementTest.php index cfab7e5d1..788849228 100644 --- a/tests/Parser/CallStatementTest.php +++ b/tests/Parser/CallStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class CallStatementTest extends TestCase { - /** - * @dataProvider callProvider - */ + #[DataProvider('callProvider')] public function testCall(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/CreateStatementTest.php b/tests/Parser/CreateStatementTest.php index 1cdd86f38..06f20f956 100644 --- a/tests/Parser/CreateStatementTest.php +++ b/tests/Parser/CreateStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class CreateStatementTest extends TestCase { - /** - * @dataProvider createProvider - */ + #[DataProvider('createProvider')] public function testCreate(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/DeleteStatementTest.php b/tests/Parser/DeleteStatementTest.php index 8d4c8744e..e80da9377 100644 --- a/tests/Parser/DeleteStatementTest.php +++ b/tests/Parser/DeleteStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class DeleteStatementTest extends TestCase { - /** - * @dataProvider deleteProvider - */ + #[DataProvider('deleteProvider')] public function testDelete(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/DropStatementTest.php b/tests/Parser/DropStatementTest.php index 21c41eb61..82afa42e8 100644 --- a/tests/Parser/DropStatementTest.php +++ b/tests/Parser/DropStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class DropStatementTest extends TestCase { - /** - * @dataProvider dropProvider - */ + #[DataProvider('dropProvider')] public function testDrop(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/ExplainStatementTest.php b/tests/Parser/ExplainStatementTest.php index ed9e5ddf4..be68cbf98 100644 --- a/tests/Parser/ExplainStatementTest.php +++ b/tests/Parser/ExplainStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ExplainStatementTest extends TestCase { - /** - * @dataProvider explainProvider - */ + #[DataProvider('explainProvider')] public function testExplain(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/InsertStatementTest.php b/tests/Parser/InsertStatementTest.php index e3c070a8f..17e22478d 100644 --- a/tests/Parser/InsertStatementTest.php +++ b/tests/Parser/InsertStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class InsertStatementTest extends TestCase { - /** - * @dataProvider insertProvider - */ + #[DataProvider('insertProvider')] public function testInsert(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/LoadStatementTest.php b/tests/Parser/LoadStatementTest.php index 75bb21a48..66d2c2a82 100644 --- a/tests/Parser/LoadStatementTest.php +++ b/tests/Parser/LoadStatementTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class LoadStatementTest extends TestCase { @@ -17,9 +18,7 @@ public function testLoadOptions(): void $this->assertEquals(10, $stmt->options->has('CONCURRENT')); } - /** - * @dataProvider loadProvider - */ + #[DataProvider('loadProvider')] public function testLoad(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/LockStatementTest.php b/tests/Parser/LockStatementTest.php index b1d25468a..0240cc878 100644 --- a/tests/Parser/LockStatementTest.php +++ b/tests/Parser/LockStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class LockStatementTest extends TestCase { - /** - * @dataProvider lockProvider - */ + #[DataProvider('lockProvider')] public function testLock(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/ParserLongExportsTest.php b/tests/Parser/ParserLongExportsTest.php index 69fe253f1..12c9c14b3 100644 --- a/tests/Parser/ParserLongExportsTest.php +++ b/tests/Parser/ParserLongExportsTest.php @@ -8,6 +8,7 @@ use PhpMyAdmin\SqlParser\Statements\SetStatement; use PhpMyAdmin\SqlParser\Statements\TransactionStatement; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ParserLongExportsTest extends TestCase { @@ -100,9 +101,7 @@ public function testParsephpMyAdminDump(): void } } - /** - * @dataProvider exportFileProvider - */ + #[DataProvider('exportFileProvider')] public function testParseExport(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/ParserTest.php b/tests/Parser/ParserTest.php index 2d79a7da3..694624dfb 100644 --- a/tests/Parser/ParserTest.php +++ b/tests/Parser/ParserTest.php @@ -9,14 +9,15 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Token; use PhpMyAdmin\SqlParser\TokensList; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\PreserveGlobalState; +use PHPUnit\Framework\Attributes\RunInSeparateProcess; use function sprintf; class ParserTest extends TestCase { - /** - * @dataProvider parseProvider - */ + #[DataProvider('parseProvider')] public function testParse(string $test): void { $this->runParserTest($test); @@ -52,10 +53,8 @@ public function testUnrecognizedKeyword(): void ); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ + #[RunInSeparateProcess] + #[PreserveGlobalState(false)] public function testError(): void { $parser = new Parser(new TokensList()); diff --git a/tests/Parser/PurgeStatementTest.php b/tests/Parser/PurgeStatementTest.php index 5d61c16b2..b54945ce3 100644 --- a/tests/Parser/PurgeStatementTest.php +++ b/tests/Parser/PurgeStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class PurgeStatementTest extends TestCase { - /** - * @dataProvider purgeProvider - */ + #[DataProvider('purgeProvider')] public function testPurge(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/RenameStatementTest.php b/tests/Parser/RenameStatementTest.php index 003d8dc9f..7fa77051c 100644 --- a/tests/Parser/RenameStatementTest.php +++ b/tests/Parser/RenameStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class RenameStatementTest extends TestCase { - /** - * @dataProvider renameProvider - */ + #[DataProvider('renameProvider')] public function testRename(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/ReplaceStatementTest.php b/tests/Parser/ReplaceStatementTest.php index e05ee6555..10bc1a436 100644 --- a/tests/Parser/ReplaceStatementTest.php +++ b/tests/Parser/ReplaceStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class ReplaceStatementTest extends TestCase { - /** - * @dataProvider replaceProvider - */ + #[DataProvider('replaceProvider')] public function testReplace(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/RestoreStatementTest.php b/tests/Parser/RestoreStatementTest.php index 124557378..237aac84d 100644 --- a/tests/Parser/RestoreStatementTest.php +++ b/tests/Parser/RestoreStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class RestoreStatementTest extends TestCase { - /** - * @dataProvider restoreProvider - */ + #[DataProvider('restoreProvider')] public function testRestore(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/SelectStatementTest.php b/tests/Parser/SelectStatementTest.php index 13aa2a0de..98486da0f 100644 --- a/tests/Parser/SelectStatementTest.php +++ b/tests/Parser/SelectStatementTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SelectStatementTest extends TestCase { @@ -17,9 +18,7 @@ public function testSelectOptions(): void $this->assertEquals(10, $stmt->options->has('MAX_STATEMENT_TIME')); } - /** - * @dataProvider selectProvider - */ + #[DataProvider('selectProvider')] public function testSelect(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/SetStatementTest.php b/tests/Parser/SetStatementTest.php index 7c5e3ed17..9614d16dd 100644 --- a/tests/Parser/SetStatementTest.php +++ b/tests/Parser/SetStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class SetStatementTest extends TestCase { - /** - * @dataProvider setProvider - */ + #[DataProvider('setProvider')] public function testSet(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/TransactionStatementTest.php b/tests/Parser/TransactionStatementTest.php index 13aa5a8ff..ce1ce6cfe 100644 --- a/tests/Parser/TransactionStatementTest.php +++ b/tests/Parser/TransactionStatementTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class TransactionStatementTest extends TestCase { @@ -20,9 +21,7 @@ public function testBuildWithoutEnd(): void ); } - /** - * @dataProvider transactionProvider - */ + #[DataProvider('transactionProvider')] public function testTransaction(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/UpdateStatementTest.php b/tests/Parser/UpdateStatementTest.php index 7f138b28b..fa00ff081 100644 --- a/tests/Parser/UpdateStatementTest.php +++ b/tests/Parser/UpdateStatementTest.php @@ -5,12 +5,11 @@ namespace PhpMyAdmin\SqlParser\Tests\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class UpdateStatementTest extends TestCase { - /** - * @dataProvider updateProvider - */ + #[DataProvider('updateProvider')] public function testUpdate(string $test): void { $this->runParserTest($test); diff --git a/tests/Parser/WithStatementTest.php b/tests/Parser/WithStatementTest.php index 7356be37e..1c0c788ad 100644 --- a/tests/Parser/WithStatementTest.php +++ b/tests/Parser/WithStatementTest.php @@ -8,12 +8,11 @@ use PhpMyAdmin\SqlParser\Lexer; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; +use PHPUnit\Framework\Attributes\DataProvider; class WithStatementTest extends TestCase { - /** - * @dataProvider parseWith - */ + #[DataProvider('parseWith')] public function testParse(string $test): void { $this->runParserTest($test); diff --git a/tests/Utils/BufferedQueryTest.php b/tests/Utils/BufferedQueryTest.php index b5e599c1b..cd4706cc4 100644 --- a/tests/Utils/BufferedQueryTest.php +++ b/tests/Utils/BufferedQueryTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\BufferedQuery; +use PHPUnit\Framework\Attributes\DataProvider; use function count; use function str_split; @@ -17,9 +18,8 @@ class BufferedQueryTest extends TestCase * @param string[] $expected * @psalm-param array{delimiter?: non-empty-string, parse_delimiter?: bool, add_delimiter?: bool} $options * @psalm-param positive-int $chunkSize - * - * @dataProvider extractProvider */ + #[DataProvider('extractProvider')] public function testExtract( string $query, int $chunkSize, diff --git a/tests/Utils/CLITest.php b/tests/Utils/CLITest.php index 80347378e..c6ea252ad 100644 --- a/tests/Utils/CLITest.php +++ b/tests/Utils/CLITest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\CLI; +use PHPUnit\Framework\Attributes\DataProvider; use function dirname; use function exec; @@ -53,9 +54,8 @@ public function testGetopt(): void /** * @param array|false $getopt - * - * @dataProvider highlightParamsProvider */ + #[DataProvider('highlightParamsProvider')] public function testRunHighlight($getopt, string $output, int $result): void { $cli = $this->getCLI($getopt); @@ -128,9 +128,8 @@ public static function highlightParamsProvider(): array /** * @param array|false $getopt - * - * @dataProvider highlightParamsStdInProvider */ + #[DataProvider('highlightParamsStdInProvider')] public function testRunHighlightStdIn(string $input, $getopt, string $output, int $result): void { $cli = $this->getCLIStdIn($input, $getopt); @@ -196,9 +195,8 @@ public static function highlightParamsStdInProvider(): array /** * @param array|false $getopt - * - * @dataProvider lintParamsStdInProvider */ + #[DataProvider('lintParamsStdInProvider')] public function testRunLintFromStdIn(string $input, $getopt, string $output, int $result): void { $cli = $this->getCLIStdIn($input, $getopt); @@ -261,9 +259,8 @@ public static function lintParamsStdInProvider(): array /** * @param array|false $getopt - * - * @dataProvider lintParamsProvider */ + #[DataProvider('lintParamsProvider')] public function testRunLint($getopt, string $output, int $result): void { $cli = $this->getCLI($getopt); @@ -328,9 +325,8 @@ public static function lintParamsProvider(): array /** * @param array|false $getopt - * - * @dataProvider tokenizeParamsProvider */ + #[DataProvider('tokenizeParamsProvider')] public function testRunTokenize($getopt, string $output, int $result): void { $cli = $this->getCLI($getopt); @@ -383,9 +379,8 @@ public static function tokenizeParamsProvider(): array /** * @param array|false $getopt - * - * @dataProvider tokenizeParamsStdInProvider */ + #[DataProvider('tokenizeParamsStdInProvider')] public function testRunTokenizeStdIn(string $input, $getopt, string $output, int $result): void { $cli = $this->getCLIStdIn($input, $getopt); @@ -435,9 +430,7 @@ public static function tokenizeParamsStdInProvider(): array ]; } - /** - * @dataProvider stdinParamsProvider - */ + #[DataProvider('stdinParamsProvider')] public function testStdinPipe(string $cmd, int $result): void { exec($cmd, $out, $ret); diff --git a/tests/Utils/FormatterTest.php b/tests/Utils/FormatterTest.php index 73a6708db..149a0ecd3 100644 --- a/tests/Utils/FormatterTest.php +++ b/tests/Utils/FormatterTest.php @@ -6,6 +6,7 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\Formatter; +use PHPUnit\Framework\Attributes\DataProvider; use ReflectionMethod; class FormatterTest extends TestCase @@ -17,9 +18,8 @@ class FormatterTest extends TestCase * @psalm-param list $default * @psalm-param list $overriding * @psalm-param list $expected - * - * @dataProvider mergeFormatsProvider */ + #[DataProvider('mergeFormatsProvider')] public function testMergeFormats(array $default, array $overriding, array $expected): void { $formatter = $this->createPartialMock(Formatter::class, ['getDefaultOptions', 'getDefaultFormats']); @@ -245,9 +245,8 @@ public static function mergeFormatsProvider(): array /** * @param array $options - * - * @dataProvider formatQueriesProviders */ + #[DataProvider('formatQueriesProviders')] public function testFormat(string $query, string $text, string $cli, string $html, array $options = []): void { // Test TEXT format diff --git a/tests/Utils/QueryTest.php b/tests/Utils/QueryTest.php index c1a365973..1c8b5deab 100644 --- a/tests/Utils/QueryTest.php +++ b/tests/Utils/QueryTest.php @@ -7,6 +7,7 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\Query; +use PHPUnit\Framework\Attributes\DataProvider; use function array_merge; @@ -18,9 +19,8 @@ class QueryTest extends TestCase /** * @param array $expected * @psalm-param QueryFlagsType $expected - * - * @dataProvider getFlagsProvider */ + #[DataProvider('getFlagsProvider')] public function testGetFlags(string $query, array $expected): void { $parser = new Parser($query); @@ -400,9 +400,8 @@ public function testGetAll(): void /** * @param string[] $expected - * - * @dataProvider getTablesProvider */ + #[DataProvider('getTablesProvider')] public function testGetTables(string $query, array $expected): void { $parser = new Parser($query); diff --git a/tests/Utils/RoutineTest.php b/tests/Utils/RoutineTest.php index 2bdf11d6b..754484a7a 100644 --- a/tests/Utils/RoutineTest.php +++ b/tests/Utils/RoutineTest.php @@ -7,14 +7,14 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\Routine; +use PHPUnit\Framework\Attributes\DataProvider; class RoutineTest extends TestCase { /** * @param string[] $expected - * - * @dataProvider getReturnTypeProvider */ + #[DataProvider('getReturnTypeProvider')] public function testGetReturnType(string $def, array $expected): void { $this->assertEquals($expected, Routine::getReturnType($def)); @@ -112,9 +112,8 @@ public static function getReturnTypeProvider(): array /** * @param string[] $expected - * - * @dataProvider getParameterProvider */ + #[DataProvider('getParameterProvider')] public function testGetParameter(string $def, array $expected): void { $this->assertEquals($expected, Routine::getParameter($def)); @@ -221,9 +220,8 @@ public static function getParameterProvider(): array * length_arr: string[][], * opts: string[] * } $expected - * - * @dataProvider getParametersProvider */ + #[DataProvider('getParametersProvider')] public function testGetParameters(string $query, array $expected): void { $parser = new Parser($query); diff --git a/tests/Utils/TableTest.php b/tests/Utils/TableTest.php index e0e7924e3..53b8648fe 100644 --- a/tests/Utils/TableTest.php +++ b/tests/Utils/TableTest.php @@ -7,6 +7,7 @@ use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Utils\Table; +use PHPUnit\Framework\Attributes\DataProvider; class TableTest extends TestCase { @@ -21,9 +22,8 @@ class TableTest extends TestCase * on_update: string, * on_delete?: string * }> $expected - * - * @dataProvider getForeignKeysProvider */ + #[DataProvider('getForeignKeysProvider')] public function testGetForeignKeys(string $query, array $expected): void { $parser = new Parser($query); @@ -146,9 +146,8 @@ public static function getForeignKeysProvider(): array * on_update_current_timestamp?: bool, * expr?: string * }> $expected - * - * @dataProvider getFieldsProvider */ + #[DataProvider('getFieldsProvider')] public function testGetFields(string $query, array $expected): void { $parser = new Parser($query); diff --git a/tests/Utils/TokensTest.php b/tests/Utils/TokensTest.php index 3cf690559..6246ddc70 100644 --- a/tests/Utils/TokensTest.php +++ b/tests/Utils/TokensTest.php @@ -7,15 +7,15 @@ use PhpMyAdmin\SqlParser\Tests\TestCase; use PhpMyAdmin\SqlParser\Token; use PhpMyAdmin\SqlParser\Utils\Tokens; +use PHPUnit\Framework\Attributes\DataProvider; class TokensTest extends TestCase { /** * @param array[] $find * @param Token[] $replace - * - * @dataProvider replaceTokensProvider */ + #[DataProvider('replaceTokensProvider')] public function testReplaceTokens(string $list, array $find, array $replace, string $expected): void { $this->assertEquals($expected, Tokens::replaceTokens($list, $find, $replace)); @@ -45,9 +45,8 @@ public static function replaceTokensProvider(): array /** * @param array $pattern - * - * @dataProvider matchProvider */ + #[DataProvider('matchProvider')] public function testMatch(Token $token, array $pattern, bool $expected): void { $this->assertSame($expected, Tokens::match($token, $pattern));