chg: upgrade to phpunit9, add pcov for coverage in docker build

pull/9143/head
Luciano Righetti 2023-06-15 16:46:22 +02:00
parent c3ec5a791f
commit 9a54a81969
5 changed files with 48 additions and 33 deletions

1
.gitignore vendored
View File

@ -10,6 +10,7 @@ webroot/scss/*.css
.vscode
docker/run/
.phpunit.result.cache
.phpunit.cache
config.json
phpunit.xml
docker-compose.override.yml

View File

@ -9,7 +9,7 @@
"admad/cakephp-social-auth": "^1.1",
"cakephp/authentication": "^2.0",
"cakephp/authorization": "^2.0",
"cakephp/cakephp": "^4.3",
"cakephp/cakephp": "^4.4",
"cakephp/migrations": "^3.0",
"cakephp/plugin-installer": "^1.2",
"erusev/parsedown": "^1.7",
@ -25,7 +25,7 @@
"josegonzalez/dotenv": "^3.2",
"league/openapi-psr7-validator": "^0.17",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^9.5",
"psy/psysh": "@stable",
"wiremock-php/wiremock-php": "^2.33"
},
@ -78,6 +78,5 @@
"dealerdirect/phpcodesniffer-composer-installer": true,
"cakephp/plugin-installer": true
}
},
"minimum-stability": "dev"
}
}

View File

@ -65,8 +65,8 @@ RUN usermod --uid $UID --gid $GID www-data
COPY . /var/www/html/
# Install development dependencies
RUN pecl install -f xdebug \
&& docker-php-ext-enable xdebug
RUN pecl install -f xdebug pcov \
&& docker-php-ext-enable xdebug pcov
# Install additional packages
RUN apt-get update \

View File

@ -1,16 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php">
<php>
<ini name="memory_limit" value="-1" />
<ini name="apc.enable_cli" value="1" />
<env name="WIREMOCK_HOST" value="localhost" />
<env name="WIREMOCK_PORT" value="8080" />
<env name="OPENAPI_SPEC" value="webroot/docs/openapi.yaml" />
<env name="SKIP_DB_MIGRATIONS" value="0" />
</php>
<!-- Add any additional test suites you want to run here -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
failOnRisky="true"
failOnWarning="false"
colors="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
<testsuite name="app">
<directory>tests/TestCase/</directory>
</testsuite>
@ -21,19 +27,22 @@
<directory>./tests/TestCase/Api</directory>
</testsuite>
</testsuites>
<extensions>
<extension class="\Cake\TestSuite\Fixture\PHPUnitExtension" />
</extensions>
<!-- Ignore vendor tests in code coverage reports -->
<filter>
<whitelist>
<php>
<ini name="memory_limit" value="-1" />
<ini name="apc.enable_cli" value="1" />
<env name="WIREMOCK_HOST" value="localhost" />
<env name="WIREMOCK_PORT" value="8080" />
<env name="OPENAPI_SPEC" value="webroot/docs/openapi.yaml" />
<env name="SKIP_DB_MIGRATIONS" value="0" />
</php>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
<directory suffix=".php">plugins/*/src/</directory>
<exclude>
<file>src/Console/Installer.php</file>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<file>src/Console/Installer.php</file>
</exclude>
</coverage>
</phpunit>

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
@ -14,6 +15,7 @@ declare(strict_types=1);
* @since 3.3.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App\Test\TestCase;
use App\Application;
@ -21,19 +23,23 @@ use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\Middleware\AssetMiddleware;
use Cake\Routing\Middleware\RoutingMiddleware;
use Cake\TestSuite\IntegrationTestCase;
use InvalidArgumentException;
use Cake\TestSuite\IntegrationTestTrait;
use Cake\TestSuite\TestCase;
/**
* ApplicationTest class
*/
class ApplicationTest extends IntegrationTestCase
class ApplicationTest extends TestCase
{
/**
* testBootstrap
*
* @return void
*/
use IntegrationTestTrait;
public function testBootstrap()
{
$app = new Application(dirname(dirname(__DIR__)) . '/config');
@ -60,7 +66,7 @@ class ApplicationTest extends IntegrationTestCase
$app = $this->getMockBuilder(Application::class)
->setConstructorArgs([dirname(dirname(__DIR__)) . '/config'])
->setMethods(['addPlugin'])
->onlyMethods(['addPlugin'])
->getMock();
$app->method('addPlugin')