Skip to content
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
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,43 @@ jobs:
with:
cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}"

test-php-with-newer-phpunit:
name: Test on PHP ${{ matrix.php }} with PHPUnit ${{ matrix.phpunit }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- {php: '8.1', phpunit: '10'}
- {php: '8.2', phpunit: '11'}
- {php: '8.3', phpunit: '12'}
- {php: '8.4', phpunit: '13'}
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Update composer.json
shell: bash
env:
PHPUNIT_VERSION: ${{ matrix.phpunit }}
run: |
composer remove --dev vimeo/psalm psalm/plugin-phpunit --no-update --no-interaction --ansi
composer require --dev phpunit/phpunit:^"$PHPUNIT_VERSION" --no-update --no-interaction --ansi

- name: Install Composer dependencies
uses: ramsey/composer-install@v4

- name: Run PHP tests
run: vendor/bin/phpunit --no-coverage --no-logging --display-all-issues

php-benchmark:
name: Benchmark on PHP ${{ matrix.php-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 3 additions & 0 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 @@ -187,6 +188,7 @@ public static function provideBuilderForRenameColumn(): Generator
/**
* @dataProvider provideBuilderForRenameColumn
*/
#[DataProvider('provideBuilderForRenameColumn')]
public function testBuilderRenameColumn(string $query): void
{
$parser = new Parser($query);
Expand Down Expand Up @@ -251,6 +253,7 @@ public static function provideBuilderForAlterRoutine(): Generator
/**
* @dataProvider provideBuilderForAlterRoutine
*/
#[DataProvider('provideBuilderForAlterRoutine')]
public function testBuilderForAlterRoutine(string $query): void
{
$parser = new Parser($query);
Expand Down
2 changes: 2 additions & 0 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;

use function implode;

Expand Down Expand Up @@ -299,6 +300,7 @@ public static function partitionQueriesProvider(): array
/**
* @dataProvider partitionQueriesProvider
*/
#[DataProvider('partitionQueriesProvider')]
public function testBuilderPartitionsEngine(string $query): void
{
$parser = new Parser($query);
Expand Down
2 changes: 2 additions & 0 deletions tests/Builder/InsertStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpMyAdmin\SqlParser\Context;
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class InsertStatementTest extends TestCase
{
Expand All @@ -29,6 +30,7 @@ protected function tearDown(): void
}

/** @dataProvider providerForTestBuilder */
#[DataProvider('providerForTestBuilder')]
public function testBuilder(string $sql): void
{
$parser = new Parser($sql);
Expand Down
2 changes: 2 additions & 0 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 @@ -42,6 +43,7 @@ public function testParseType(): void
/**
* @dataProvider parseProvider
*/
#[DataProvider('parseProvider')]
public function testParse(string $test): void
{
$this->runParserTest($test);
Expand Down
4 changes: 4 additions & 0 deletions tests/Components/ComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use PhpMyAdmin\SqlParser\Parser;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PhpMyAdmin\SqlParser\TokensList;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use Throwable;

class ComponentTest extends TestCase
Expand All @@ -16,6 +18,8 @@ class ComponentTest extends TestCase
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function testParse(): void
{
$this->expectExceptionMessage('Not implemented yet.');
Expand Down
3 changes: 3 additions & 0 deletions tests/Components/ExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -42,6 +43,7 @@ public function testParse3(): void
/**
* @dataProvider parseErrProvider
*/
#[DataProvider('parseErrProvider')]
public function testParseErr(string $expr, string $error): void
{
$parser = new Parser();
Expand Down Expand Up @@ -145,6 +147,7 @@ public static function mysqlCommandsProvider(): array
/**
* @dataProvider mysqlCommandsProvider
*/
#[DataProvider('mysqlCommandsProvider')]
public function testMysqlCommands(string $expr, string $expected): void
{
$parser = new Parser($expr, true);
Expand Down
2 changes: 2 additions & 0 deletions tests/Components/GroupKeywordTest.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\Components\GroupKeyword;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

use function array_map;

Expand Down Expand Up @@ -56,6 +57,7 @@ public static function provideExpressions(): Generator
*
* @dataProvider provideExpressions
*/
#[DataProvider('provideExpressions')]
public function testBuild($component, string $expected): void
{
$this->assertSame($expected, GroupKeyword::build($component));
Expand Down
2 changes: 2 additions & 0 deletions tests/Components/LimitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpMyAdmin\SqlParser\Components\Limit;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;

class LimitTest extends TestCase
{
Expand All @@ -24,6 +25,7 @@ public function testBuildWithOffset(): void
/**
* @dataProvider parseProvider
*/
#[DataProvider('parseProvider')]
public function testParse(string $test): void
{
$this->runParserTest($test);
Expand Down
2 changes: 2 additions & 0 deletions tests/Components/LockExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -30,6 +31,7 @@ public function testParse2(): void
/**
* @dataProvider parseErrProvider
*/
#[DataProvider('parseErrProvider')]
public function testParseErr(string $expr, string $error): void
{
$parser = new Parser();
Expand Down
5 changes: 5 additions & 0 deletions tests/Lexer/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpMyAdmin\SqlParser\Context;
use PhpMyAdmin\SqlParser\Contexts;
use PhpMyAdmin\SqlParser\Tests\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Throwable;

use function class_exists;
Expand Down Expand Up @@ -37,6 +38,7 @@ public function testLoad(): void
*
* @dataProvider contextLoadingProvider
*/
#[DataProvider('contextLoadingProvider')]
public function testLoadClosest(string $context, ?string $expected): void
{
$this->assertEquals($expected, Context::loadClosest($context));
Expand Down Expand Up @@ -90,6 +92,7 @@ public static function contextLoadingProvider(): array
/**
* @dataProvider contextNamesProvider
*/
#[DataProvider('contextNamesProvider')]
public function testLoadAll(string $context): void
{
Context::load($context);
Expand Down Expand Up @@ -148,6 +151,7 @@ public static function contextNamesProvider(): array
/**
* @dataProvider contextClassesProvider
*/
#[DataProvider('contextClassesProvider')]
public function testLoadAllByClass(string $context): void
{
Context::load($context);
Expand Down Expand Up @@ -217,6 +221,7 @@ public function testLoadError(): void
*
* @dataProvider providerForTestMode
*/
#[DataProvider('providerForTestMode')]
public function testMode($mode, int $expected): void
{
Context::setMode($mode);
Expand Down
6 changes: 6 additions & 0 deletions tests/Lexer/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
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;

Expand All @@ -16,6 +19,8 @@ class LexerTest extends TestCase
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function testError(): void
{
$lexer = new Lexer('');
Expand Down Expand Up @@ -51,6 +56,7 @@ public function testErrorStrict(): void
/**
* @dataProvider lexProvider
*/
#[DataProvider('lexProvider')]
public function testLex(string $test): void
{
$this->runParserTest($test);
Expand Down
2 changes: 2 additions & 0 deletions tests/Misc/BugsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
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);
Expand Down
2 changes: 2 additions & 0 deletions tests/Misc/ParameterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
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);
Expand Down
7 changes: 7 additions & 0 deletions tests/Misc/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use PhpMyAdmin\MoTranslator\Loader;
use PhpMyAdmin\MoTranslator\Translator as MoTranslator;
use PhpMyAdmin\SqlParser\Translator;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\TestWith;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use ReflectionProperty;
Expand All @@ -16,6 +18,7 @@
use const PHP_VERSION_ID;

/** @covers \PhpMyAdmin\SqlParser\Translator */
#[CoversClass(Translator::class)]
final class TranslatorTest extends TestCase
{
public static function tearDownAfterClass(): void
Expand Down Expand Up @@ -51,6 +54,10 @@ public function testLocale(): void
* ["en", "", "en"]
* ["fr", "", "fr"]
*/
#[TestWith([null, 'en', 'en'])]
#[TestWith([null, 'fr', 'fr'])]
#[TestWith(['en', '', 'en'])]
#[TestWith(['fr', '', 'fr'])]
public function testLoad(?string $globalLang, string $locale, string $expectedLocale): void
{
$loaderProperty = new ReflectionProperty(Translator::class, 'loader');
Expand Down
2 changes: 2 additions & 0 deletions tests/Misc/UtfStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PhpMyAdmin\SqlParser\Tests\TestCase;
use PhpMyAdmin\SqlParser\UtfString;
use PHPUnit\Framework\Attributes\DataProvider;
use Throwable;

use function chr;
Expand Down Expand Up @@ -86,6 +87,7 @@ public function testToString(): void
*
* @dataProvider utf8StringsProvider
*/
#[DataProvider('utf8StringsProvider')]
public function testAccess(string $text, ?string $pos10, ?string $pos20): void
{
$str = new UtfString($text);
Expand Down
2 changes: 2 additions & 0 deletions tests/Parser/AlterStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
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);
Expand Down
2 changes: 2 additions & 0 deletions tests/Parser/AnalyzeStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
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);
Expand Down
2 changes: 2 additions & 0 deletions tests/Parser/CallStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
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);
Expand Down
Loading