Skip to content

Commit

Permalink
Upgrade PHPUnit to version 10.0
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Feb 22, 2023
1 parent ceaee6c commit efb0c45
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-selenium.yml
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -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",
Expand Down
20 changes: 9 additions & 11 deletions phpunit.xml.dist
@@ -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>
Expand All @@ -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>
Expand Down
6 changes: 5 additions & 1 deletion psalm-baseline.xml
Expand Up @@ -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>
Expand Down Expand Up @@ -18200,7 +18203,8 @@
<code><![CDATA['']]></code>
</DocblockTypeContradiction>
<InternalMethod>
<code>getName</code>
<code>name</code>
<code>status</code>
</InternalMethod>
<MixedArgument>
<code>$lastWindow</code>
Expand Down
9 changes: 5 additions & 4 deletions test/bootstrap-dist.php
Expand Up @@ -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
}

/**
Expand Down
6 changes: 0 additions & 6 deletions test/classes/AbstractNetworkTestCase.php
Expand Up @@ -14,7 +14,6 @@
use ReflectionProperty;

use function array_slice;
use function call_user_func_array;
use function count;
use function end;
use function is_array;
Expand Down Expand Up @@ -74,11 +73,6 @@ public function mockResponse(...$param): MockObject
->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')
Expand Down
1 change: 0 additions & 1 deletion test/classes/ErrorHandlerTest.php
Expand Up @@ -342,7 +342,6 @@ public function testHandleExceptionForProdEnv(): void
$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);
}
}
4 changes: 2 additions & 2 deletions test/classes/ErrorTest.php
Expand Up @@ -120,7 +120,7 @@ public function testGetHash(): void
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()
);
}
Expand All @@ -138,7 +138,7 @@ public function testGetDisplay(): void
$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);
Expand Down
2 changes: 1 addition & 1 deletion test/classes/ListDatabaseTest.php
Expand Up @@ -7,7 +7,7 @@
use PhpMyAdmin\ListDatabase;

/**
* @covers \PhpMyAdmin\ListDatabase<extended>
* @covers \PhpMyAdmin\ListDatabase
*/
class ListDatabaseTest extends AbstractTestCase
{
Expand Down
38 changes: 0 additions & 38 deletions test/phpunit-php-nightly.xml

This file was deleted.

6 changes: 3 additions & 3 deletions test/selenium/TestBase.php
Expand Up @@ -285,7 +285,7 @@ public function getTestName(): string
{
$className = substr(static::class, strlen('PhpMyAdmin\Tests\Selenium\\'));

return $className . ': ' . $this->getName();
return $className . ': ' . $this->name();
}

/**
Expand Down Expand Up @@ -1116,7 +1116,7 @@ protected function tearDown(): void
$this->dbQuery('DROP DATABASE IF EXISTS `phpmyadmin`;');
}

if ($this->hasFailed()) {
if ($this->status()->asString() !== 'success') {
return;
}

Expand Down Expand Up @@ -1205,7 +1205,7 @@ private function getErrorVideoUrl(): void
/**
* 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');
Expand Down

0 comments on commit efb0c45

Please sign in to comment.