Skip to content

Commit

Permalink
use different base PHPUnit config for each PHPUnit version
Browse files Browse the repository at this point in the history
  • Loading branch information
rimelek committed Mar 19, 2023
1 parent 87b0f1c commit 29eafc0
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_7_2_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_7_3_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_7_4_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_8_0_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_8_1_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_8_2_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/PHPUnit__PHP_ALL_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions php/bin/php.sh
Expand Up @@ -30,7 +30,6 @@ PROJECT_ROOT="$(cd "$CURR_DIR/../.." && pwd)"
PHP_UNIT_PATH="$PROJECT_ROOT/php/bin/phpunit.php"
PHP_UNIT_XML="$PROJECT_ROOT/php/phpunit/phpunit.xml"
PHP_UNIT_XML_CACHE_DIR="$PROJECT_ROOT/php/phpunit"
PHP_UNIT_XML_CACHE="$PHP_UNIT_XML_CACHE_DIR/phpunit.php-$PHP_VERSION.xml"

ARGS=("$@")

Expand Down Expand Up @@ -78,9 +77,6 @@ function arg_exists() {
if arg_exists "$PHP_UNIT_PATH" \
&& arg_value_is "--configuration" "$PHP_UNIT_XML"; then
mkdir -p "$PHP_UNIT_XML_CACHE_DIR"
export PHP_UNIT_TESTSUITE_NAME="test $PHP_VERSION"
envsubst < "$PHP_UNIT_XML" > "$PHP_UNIT_XML_CACHE"
arg_value_set "--configuration" "$PHP_UNIT_XML_CACHE"
if [[ "$PHP_VERSION" != "7.0" ]] && [[ "$PHP_VERSION" != "5.6" ]]; then
arg_value_set "--cache-result-file" "$PHP_UNIT_XML_CACHE_DIR/.phpunit.result.php-$PHP_VERSION.cache"
fi
Expand Down
17 changes: 16 additions & 1 deletion php/bin/phpunit.php
Expand Up @@ -22,6 +22,16 @@
$phpUnitCacheDir = $projectRoot . '/php/phpunit';
$phpUnitPharPath = $phpUnitCacheDir . '/phpunit-' . $phpUnitVersion . '.phar';
$phpUnitPharURL = 'https://phar.phpunit.de/phpunit-' . $phpUnitVersion . '.phar';
$phpUnitXML = $projectRoot . '/php/phpunit/phpunit-' . $phpUnitVersion . '.xml';
$phpUnitXMLCache = $phpUnitCacheDir . '/phpunit.php-' . $phpVersion . '.xml';

file_put_contents($phpUnitXMLCache,
preg_replace(
'/\$\{PHP_UNIT_TESTSUITE_NAME}/',
'test ' . $phpVersion,
file_get_contents($phpUnitXML)
)
);

if (!file_exists($phpUnitPharPath)) {
file_put_contents($phpUnitPharPath, file_get_contents($phpUnitPharURL));
Expand All @@ -30,7 +40,12 @@
array_shift($argv);

$cmd = ['php', escapeshellcmd($phpUnitPharPath)];
foreach ($argv as $v) {
foreach ($argv as $k => $v) {
if ($k > 0 and $argv[$k - 1] == '--configuration') {
$cmd[] = $phpUnitXMLCache;
continue;
}

// PHPStorm fix for PHP 5.6
if ($phpVersion == '5.6' and $v == '--teamcity') {
continue;
Expand Down
18 changes: 18 additions & 0 deletions php/phpunit/phpunit-4.8.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite name="${PHP_UNIT_TESTSUITE_NAME}">
<directory>../../test</directory>
</testsuite>

<filter>
<whitelist>
<directory suffix=".php">../../src</directory>
</whitelist>
</filter>

</phpunit>
18 changes: 18 additions & 0 deletions php/phpunit/phpunit-6.5.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd"
bootstrap="../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite name="${PHP_UNIT_TESTSUITE_NAME}">
<directory>../../test</directory>
</testsuite>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../../src</directory>
</whitelist>
</filter>

</phpunit>
18 changes: 18 additions & 0 deletions php/phpunit/phpunit-7.5.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite name="${PHP_UNIT_TESTSUITE_NAME}">
<directory>../../test</directory>
</testsuite>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../../src</directory>
</whitelist>
</filter>

</phpunit>
2 changes: 0 additions & 2 deletions php/phpunit/phpunit.xml → php/phpunit/phpunit-8.5.xml
Expand Up @@ -2,8 +2,6 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="../../vendor/autoload.php"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
Expand Down
18 changes: 18 additions & 0 deletions php/phpunit/phpunit-9.6.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuite name="${PHP_UNIT_TESTSUITE_NAME}">
<directory>../../test</directory>
</testsuite>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../../src</directory>
</include>
</coverage>

</phpunit>

0 comments on commit 29eafc0

Please sign in to comment.