From efb0c451cd2928763209948abc898f2f8064a0a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 22 Feb 2023 17:19:20 -0300 Subject: [PATCH] Upgrade PHPUnit to version 10.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- .github/workflows/test-selenium.yml | 2 +- .github/workflows/tests.yml | 6 ++-- composer.json | 4 +-- phpunit.xml.dist | 20 ++++++------- psalm-baseline.xml | 6 +++- test/bootstrap-dist.php | 9 +++--- test/classes/AbstractNetworkTestCase.php | 6 ---- test/classes/ErrorHandlerTest.php | 1 - test/classes/ErrorTest.php | 4 +-- test/classes/ListDatabaseTest.php | 2 +- test/phpunit-php-nightly.xml | 38 ------------------------ test/selenium/TestBase.php | 6 ++-- 12 files changed, 30 insertions(+), 74 deletions(-) delete mode 100644 test/phpunit-php-nightly.xml diff --git a/.github/workflows/test-selenium.yml b/.github/workflows/test-selenium.yml index e54a727345..12b0f2d2df 100644 --- a/.github/workflows/test-selenium.yml +++ b/.github/workflows/test-selenium.yml @@ -139,7 +139,7 @@ jobs: TESTSUITE_DATABASE_PREFIX: "selenium" TESTSUITE_SELENIUM_HOST: "127.0.0.1" TESTSUITE_SELENIUM_PORT: "4444" - run: ./vendor/bin/phpunit --testsuite selenium --verbose --debug --no-coverage --stop-on-skipped test/selenium/${{ matrix.test-name }}Test.php + run: ./vendor/bin/phpunit --testsuite selenium --no-logging --no-coverage --stop-on-skipped test/selenium/${{ matrix.test-name }}Test.php - name: Output logs and stop server env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c456abb3c5..a018c38378 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: composer config version "$(php -r "define('VERSION_SUFFIX', ''); require_once('libraries/classes/Version.php'); echo \PhpMyAdmin\Version::VERSION;")" && \ composer update && \ ./scripts/generate-mo && \ - php\$V -d memory_limit=512M ./vendor/bin/phpunit --no-coverage --testsuite unit --exclude-group=%s" \ + php\$V -d memory_limit=512M ./vendor/bin/phpunit --no-logging --no-coverage --testsuite unit --exclude-group=%s" \ "${{ matrix.php-version }}" "${{ matrix.exclude-phpunit-groups }}" > ./do-tests.sh - name: Set up multi arch support @@ -69,13 +69,11 @@ jobs: php-version: ["8.1", "8.2"] experimental: [false] os: [ubuntu-latest] - phpunit-options: ['--testsuite unit'] php-extensions: ['mbstring, iconv, mysqli, zip, gd, bz2'] include: - php-version: 'nightly' experimental: true os: ubuntu-latest - phpunit-options: '--configuration test/phpunit-php-nightly.xml' composer-options: '--ignore-platform-req=php+' php-extensions: 'mbstring, iconv, mysqli, zip, bz2' steps: @@ -105,7 +103,7 @@ jobs: composer-options: ${{ matrix.composer-options }} - name: Run PHP tests - run: composer run phpunit -- ${{ matrix.phpunit-options }} + run: composer run phpunit -- --testsuite unit - name: Send coverage uses: codecov/codecov-action@v3 diff --git a/composer.json b/composer.json index c49dad06e8..42bcb6dc8b 100644 --- a/composer.json +++ b/composer.json @@ -97,14 +97,14 @@ "require-dev": { "bacon/bacon-qr-code": "^2.0", "code-lts/u2f-php-server": "^1.2", - "php-webdriver/webdriver": "^1.13", + "php-webdriver/webdriver": "^1.14", "phpmyadmin/coding-standard": "^4.0", "phpstan/extension-installer": "^1.2", "phpstan/phpstan": "^1.10", "phpstan/phpstan-phpunit": "^1.3", "phpstan/phpstan-strict-rules": "^1.5", "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.0", "pragmarx/google2fa-qrcode": "^2.1", "psalm/plugin-phpunit": "^0.18.4", "roave/security-advisories": "dev-latest", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b5e4e045d4..8b08324123 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,14 @@ @@ -28,8 +28,6 @@ - - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 8595de40a8..65f1865038 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -15979,6 +15979,9 @@ $http_response_code_param + + $param + @@ -18200,7 +18203,8 @@ - getName + name + status $lastWindow diff --git a/test/bootstrap-dist.php b/test/bootstrap-dist.php index 57cc42a7b1..1afd5cb748 100644 --- a/test/bootstrap-dist.php +++ b/test/bootstrap-dist.php @@ -2,18 +2,19 @@ declare(strict_types=1); +// phpcs:disable PSR1.Files.SideEffects + +define('PHPMYADMIN', true); +define('TESTSUITE', true); + if (! defined('ROOT_PATH')) { - // phpcs:disable PSR1.Files.SideEffects define('ROOT_PATH', dirname(__DIR__) . DIRECTORY_SEPARATOR); - // phpcs:enable } if (! defined('TEST_PATH')) { // This is used at Debian because tests // can be in a different place than the source code - // phpcs:disable PSR1.Files.SideEffects define('TEST_PATH', ROOT_PATH); - // phpcs:enable } /** diff --git a/test/classes/AbstractNetworkTestCase.php b/test/classes/AbstractNetworkTestCase.php index d8a8de6b63..131f1fef38 100644 --- a/test/classes/AbstractNetworkTestCase.php +++ b/test/classes/AbstractNetworkTestCase.php @@ -14,7 +14,6 @@ use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; use function array_slice; -use function call_user_func_array; use function count; use function end; use function is_array; @@ -74,11 +73,6 @@ abstract class AbstractNetworkTestCase extends AbstractTestCase ->method('httpResponseCode')->with($http_response_code_param); } } - - $header_method = $mockResponse->expects($this->exactly(count($param))) - ->method('header'); - - call_user_func_array([$header_method, 'withConsecutive'], $param); } else { $mockResponse->expects($this->once()) ->method('header') diff --git a/test/classes/ErrorHandlerTest.php b/test/classes/ErrorHandlerTest.php index d38dc7fd09..4fc0b3fc01 100644 --- a/test/classes/ErrorHandlerTest.php +++ b/test/classes/ErrorHandlerTest.php @@ -342,7 +342,6 @@ class ErrorHandlerTest extends AbstractTestCase $this->assertSame('Exception: Exception message.', $error->getOnlyMessage()); $this->assertStringContainsString($error->getDisplay(), $output); $this->assertStringContainsString('Exception: Exception message.', $output); - $this->assertStringNotContainsString('Internal error', $output); $this->assertStringNotContainsString('ErrorHandlerTest.php#' . $error->getLine(), $output); } } diff --git a/test/classes/ErrorTest.php b/test/classes/ErrorTest.php index 770f5602dd..fd08793712 100644 --- a/test/classes/ErrorTest.php +++ b/test/classes/ErrorTest.php @@ -120,7 +120,7 @@ class ErrorTest extends AbstractTestCase public function testGetBacktraceDisplay(): void { $this->assertStringContainsString( - 'PHPUnit\Framework\TestResult->run()', + 'PHPUnit\Framework\TestRunner->run()', $this->object->getBacktraceDisplay() ); } @@ -138,7 +138,7 @@ class ErrorTest extends AbstractTestCase $actual ); $this->assertStringContainsString( - 'PHPUnit\Framework\TestResult->run()
  • ', + 'PHPUnit\Framework\TestRunner->run()
  • ', $actual ); $this->assertStringEndsWith('
  • ' . "\n", $actual); diff --git a/test/classes/ListDatabaseTest.php b/test/classes/ListDatabaseTest.php index ba32b5cf6f..1ee91659c1 100644 --- a/test/classes/ListDatabaseTest.php +++ b/test/classes/ListDatabaseTest.php @@ -7,7 +7,7 @@ namespace PhpMyAdmin\Tests; use PhpMyAdmin\ListDatabase; /** - * @covers \PhpMyAdmin\ListDatabase + * @covers \PhpMyAdmin\ListDatabase */ class ListDatabaseTest extends AbstractTestCase { diff --git a/test/phpunit-php-nightly.xml b/test/phpunit-php-nightly.xml deleted file mode 100644 index baef0c2f16..0000000000 --- a/test/phpunit-php-nightly.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - classes - - - - - - . - - ../examples - ../libraries/cache - ../node_modules - ../test - ../tmp - ../vendor - - - - diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php index da05a9c194..1039c1396e 100644 --- a/test/selenium/TestBase.php +++ b/test/selenium/TestBase.php @@ -285,7 +285,7 @@ abstract class TestBase extends TestCase { $className = substr(static::class, strlen('PhpMyAdmin\Tests\Selenium\\')); - return $className . ': ' . $this->getName(); + return $className . ': ' . $this->name(); } /** @@ -1116,7 +1116,7 @@ JS; $this->dbQuery('DROP DATABASE IF EXISTS `phpmyadmin`;'); } - if ($this->hasFailed()) { + if ($this->status()->asString() !== 'success') { return; } @@ -1205,7 +1205,7 @@ JS; /** * Mark unsuccessful tests as 'Failures' on Browerstack */ - public function onNotSuccessfulTest(Throwable $t): void + public function onNotSuccessfulTest(Throwable $t): never { $this->markTestAs('failed', $t->getMessage()); $this->takeScrenshot('test_failed');