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

Use PHPUnit attributes over annotations #495

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory="build/.phpunit.cache"
executionOrder="random"
Expand Down Expand Up @@ -36,10 +36,12 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<xml outputDirectory="build/logs/coverage-xml"/>
Expand Down
198 changes: 197 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.13.1@086b94371304750d1c673315321a55d15fc59015">
<files psalm-version="5.14.1@b9d355e0829c397b9b3b47d0c0ed042a8a70284d">
<file src="src/Components/AlterOperation.php">
<ArgumentTypeCoercion>
<code><![CDATA[$component->partitions]]></code>
Expand Down Expand Up @@ -1481,6 +1481,11 @@
<code><![CDATA[$list->tokens]]></code>
</UndefinedPropertyFetch>
</file>
<file src="tests/Builder/AlterStatementTest.php">
<PossiblyUnusedMethod>
<code>provideBuilderForRenameColumn</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Builder/CreateStatementTest.php">
<PossiblyInvalidArgument>
<code><![CDATA[$stmt->fields]]></code>
Expand All @@ -1498,8 +1503,19 @@
<code>isEmpty</code>
<code>isEmpty</code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code>partitionQueriesProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Builder/StatementTest.php">
<PossiblyUnusedMethod>
<code>getAliasesProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Components/ArrayObjTest.php">
<PossiblyUnusedMethod>
<code>parseProvider</code>
</PossiblyUnusedMethod>
<UndefinedMethod>
<code>$components</code>
<code>$components</code>
Expand Down Expand Up @@ -1564,6 +1580,15 @@
<code><![CDATA[$component->table]]></code>
<code><![CDATA[$component->table]]></code>
</PossiblyNullPropertyFetch>
<PossiblyUnusedMethod>
<code>mysqlCommandsProvider</code>
<code>parseErrProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Components/GroupKeywordTest.php">
<PossiblyUnusedMethod>
<code>provideExpressions</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Components/JoinKeywordTest.php">
<DocblockTypeContradiction>
Expand All @@ -1578,7 +1603,15 @@
<code>assertNull</code>
</DocblockTypeContradiction>
</file>
<file src="tests/Components/LimitTest.php">
<PossiblyUnusedMethod>
<code>parseProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Components/LockExpressionTest.php">
<PossiblyUnusedMethod>
<code>parseErrProvider</code>
</PossiblyUnusedMethod>
<RedundantConditionGivenDocblockType>
<code>assertNotNull</code>
<code>assertNotNull</code>
Expand All @@ -1595,10 +1628,85 @@
<code>$component</code>
</InvalidArgument>
</file>
<file src="tests/Lexer/ContextTest.php">
<PossiblyUnusedMethod>
<code>contextLoadingProvider</code>
<code>contextNamesProvider</code>
<code>providerForTestMode</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Lexer/LexerTest.php">
<PossiblyUnusedMethod>
<code>lexProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Misc/BugsTest.php">
<PossiblyUnusedMethod>
<code>bugProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Misc/ParameterTest.php">
<PossiblyUnusedMethod>
<code>parameterProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Misc/UtfStringTest.php">
<PossiblyUnusedMethod>
<code>utf8StringsProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/AlterStatementTest.php">
<PossiblyUnusedMethod>
<code>alterProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/AnalyzeStatementTest.php">
<PossiblyUnusedMethod>
<code>analyzeProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/CallStatementTest.php">
<PossiblyUnusedMethod>
<code>callProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/CreateStatementTest.php">
<PossiblyUnusedMethod>
<code>createProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/DeleteStatementTest.php">
<PossiblyUnusedMethod>
<code>deleteProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/DropStatementTest.php">
<PossiblyUnusedMethod>
<code>dropProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/ExplainStatementTest.php">
<PossiblyUnusedMethod>
<code>explainProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/InsertStatementTest.php">
<PossiblyUnusedMethod>
<code>insertProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/LoadStatementTest.php">
<PossiblyNullReference>
<code>has</code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code>loadProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/LockStatementTest.php">
<PossiblyUnusedMethod>
<code>lockProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/ParserLongExportsTest.php">
<MixedAssignment>
Expand All @@ -1607,11 +1715,62 @@
<PossiblyNullIterator>
<code><![CDATA[$statement->statements]]></code>
</PossiblyNullIterator>
<PossiblyUnusedMethod>
<code>exportFileProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/ParserTest.php">
<PossiblyUnusedMethod>
<code>parseProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/PurgeStatementTest.php">
<PossiblyUnusedMethod>
<code>purgeProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/RenameStatementTest.php">
<PossiblyUnusedMethod>
<code>renameProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/ReplaceStatementTest.php">
<PossiblyUnusedMethod>
<code>replaceProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/RestoreStatementTest.php">
<PossiblyUnusedMethod>
<code>restoreProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/SelectStatementTest.php">
<PossiblyNullReference>
<code>has</code>
</PossiblyNullReference>
<PossiblyUnusedMethod>
<code>selectProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/SetStatementTest.php">
<PossiblyUnusedMethod>
<code>setProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/TransactionStatementTest.php">
<PossiblyUnusedMethod>
<code>transactionProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/UpdateStatementTest.php">
<PossiblyUnusedMethod>
<code>updateProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Parser/WithStatementTest.php">
<PossiblyUnusedMethod>
<code>parseWith</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/TestCase.php">
<InvalidReturnStatement>
Expand All @@ -1635,7 +1794,27 @@
<code>TestContext</code>
</UnusedClass>
</file>
<file src="tests/Utils/BufferedQueryTest.php">
<PossiblyUnusedMethod>
<code>extractProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Utils/CLITest.php">
<PossiblyUnusedMethod>
<code>highlightParamsProvider</code>
<code>highlightParamsStdInProvider</code>
<code>lintParamsProvider</code>
<code>lintParamsStdInProvider</code>
<code>stdinParamsProvider</code>
<code>tokenizeParamsProvider</code>
<code>tokenizeParamsStdInProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Utils/FormatterTest.php">
<PossiblyUnusedMethod>
<code>formatQueriesProviders</code>
<code>mergeFormatsProvider</code>
</PossiblyUnusedMethod>
<UnusedMethodCall>
<code>setAccessible</code>
</UnusedMethodCall>
Expand All @@ -1659,6 +1838,10 @@
<code><![CDATA[$parser->list]]></code>
<code><![CDATA[$parser->list]]></code>
</PossiblyNullArgument>
<PossiblyUnusedMethod>
<code>getFlagsProvider</code>
<code>getTablesProvider</code>
</PossiblyUnusedMethod>
<UnusedVariable>
<code>$delimiter</code>
<code>$delimiter</code>
Expand All @@ -1669,6 +1852,11 @@
<ArgumentTypeCoercion>
<code><![CDATA[$parser->statements[0]]]></code>
</ArgumentTypeCoercion>
<PossiblyUnusedMethod>
<code>getParameterProvider</code>
<code>getParametersProvider</code>
<code>getReturnTypeProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Utils/TableTest.php">
<ArgumentTypeCoercion>
Expand Down Expand Up @@ -1777,11 +1965,19 @@
* expr?: string
* }>}>]]></code>
</InvalidReturnType>
<PossiblyUnusedMethod>
<code>getFieldsProvider</code>
<code>getForeignKeysProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/Utils/TokensTest.php">
<InvalidArgument>
<code>$find</code>
</InvalidArgument>
<PossiblyUnusedMethod>
<code>matchProvider</code>
<code>replaceTokensProvider</code>
</PossiblyUnusedMethod>
</file>
<file src="tests/benchmarks/UtfStringBench.php">
<MissingConstructor>
Expand Down
5 changes: 2 additions & 3 deletions tests/Builder/AlterStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Generator;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class AlterStatementTest extends TestCase
{
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions tests/Builder/CreateStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -299,9 +300,7 @@ public static function partitionQueriesProvider(): array
];
}

/**
* @dataProvider partitionQueriesProvider
*/
#[DataProvider('partitionQueriesProvider')]
public function testBuilderPartitionsEngine(string $query): void
{
$parser = new Parser($query);
Expand Down
4 changes: 2 additions & 2 deletions tests/Builder/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -46,9 +47,8 @@ public function testBuilder(): void
* alias: (string|null),
* tables: array<string, array{alias: (string|null), columns: array<string, string>}>
* }> $expected
*
* @dataProvider getAliasesProvider
*/
#[DataProvider('getAliasesProvider')]
public function testGetAliases(string $query, string $db, array $expected): void
{
$parser = new Parser($query);
Expand Down
5 changes: 2 additions & 3 deletions tests/Components/ArrayObjTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down
Loading
Loading