Upgrade PHPUnit to version 10.0

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2023-02-22 17:19:20 -03:00
parent ceaee6ccb8
commit efb0c451cd
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
12 changed files with 30 additions and 74 deletions

View File

@ -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:

View File

@ -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

View File

@ -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",

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="test/bootstrap-dist.php"
colors="true"
forceCoversAnnotation="true"
verbose="true"
executionOrder="random"
defaultTestSuite="unit"
failOnIncomplete="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="test/bootstrap-dist.php"
colors="true"
executionOrder="random"
defaultTestSuite="unit"
failOnIncomplete="true"
cacheDirectory="build/.phpunit.cache"
requireCoverageMetadata="true"
>
<coverage>
<include>
@ -28,8 +28,6 @@
</report>
</coverage>
<php>
<const name="PHPMYADMIN" value="1"/>
<const name="TESTSUITE" value="1"/>
<env name="LC_ALL" value="C.UTF8" force="true"/>
</php>
<testsuites>

View File

@ -15979,6 +15979,9 @@
<MixedAssignment>
<code>$http_response_code_param</code>
</MixedAssignment>
<UnusedVariable>
<code>$param</code>
</UnusedVariable>
</file>
<file src="test/classes/AbstractTestCase.php">
<PossiblyUndefinedArrayOffset>
@ -18200,7 +18203,8 @@
<code><![CDATA['']]></code>
</DocblockTypeContradiction>
<InternalMethod>
<code>getName</code>
<code>name</code>
<code>status</code>
</InternalMethod>
<MixedArgument>
<code>$lastWindow</code>

View File

@ -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
}
/**

View File

@ -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')

View File

@ -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);
}
}

View File

@ -120,7 +120,7 @@ class ErrorTest extends AbstractTestCase
public function testGetBacktraceDisplay(): void
{
$this->assertStringContainsString(
'PHPUnit\Framework\TestResult->run(<Class:PhpMyAdmin\Tests\ErrorTest>)',
'PHPUnit\Framework\TestRunner->run(<Class:PhpMyAdmin\Tests\ErrorTest>)',
$this->object->getBacktraceDisplay()
);
}
@ -138,7 +138,7 @@ class ErrorTest extends AbstractTestCase
$actual
);
$this->assertStringContainsString(
'PHPUnit\Framework\TestResult->run(<Class:PhpMyAdmin\Tests\ErrorTest>)</li><li class="list-group-item">',
'PHPUnit\Framework\TestRunner->run(<Class:PhpMyAdmin\Tests\ErrorTest>)</li><li class="list-group-item">',
$actual
);
$this->assertStringEndsWith('</li></ol></div>' . "\n", $actual);

View File

@ -7,7 +7,7 @@ namespace PhpMyAdmin\Tests;
use PhpMyAdmin\ListDatabase;
/**
* @covers \PhpMyAdmin\ListDatabase<extended>
* @covers \PhpMyAdmin\ListDatabase
*/
class ListDatabaseTest extends AbstractTestCase
{

View File

@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="bootstrap-dist.php"
convertDeprecationsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
convertErrorsToExceptions="false"
forceCoversAnnotation="true"
executionOrder="random"
colors="true"
verbose="true">
<php>
<const name="PHPMYADMIN" value="1"/>
<const name="TESTSUITE" value="1"/>
</php>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">classes</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">.</directory>
<exclude>
<directory>../examples</directory>
<directory>../libraries/cache</directory>
<directory>../node_modules</directory>
<directory>../test</directory>
<directory>../tmp</directory>
<directory>../vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@ -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');