Skip to content

Commit

Permalink
CI - test latest tools on php 7.4
Browse files Browse the repository at this point in the history
https://github.com/EdgedesignCZ/phpqa/pull/219/checks?check_run_id=1821013012#step:6:7
PHP Fatal error:  Declaration of Edge\QA\OptionsTest::setUp() must be compatible with PHPUnit\Framework\TestCase::setUp(): void

https://github.com/EdgedesignCZ/phpqa/pull/219/checks?check_run_id=1821044568#step:6:829
Ignore not installed phpcpd, it will be fixed in another PR.
  • Loading branch information
zdenekdrahos committed Feb 3, 2021
1 parent d853d37 commit b0f1c6f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4]
php: [7.4]
stability: [prefer-stable]

steps:
Expand Down Expand Up @@ -51,16 +51,36 @@ jobs:
# 4) install suggested tools
bin/suggested-tools.sh install;
fi
if [[ ${CI_PHP_VERSION:0:3} == "7.4" ]]; then
# 1) delete sebastian dependency hell
composer remove phpunit/phpunit --dev --no-interaction && composer remove sebastian/phpcpd --no-interaction;
# 2) update tools
composer update;
# 3) reinstall latest versions TODO: phpcpd v6
composer require phpunit/phpunit --dev;
# 4) install suggested tools
bin/suggested-tools.sh install;
# 5) fix new php versions
php tests/.phpunit/fix-typehints.php
fi
# test installing suggested tools like docker image
if [[ ${CI_PHP_VERSION:0:3} == "7.2" ]]; then
bin/suggested-tools.sh install --prefer-dist;
fi
echo
composer outdated --direct --all
- name: Run tests
env:
CI_PHP_VERSION: ${{ matrix.php }}
run: |
vendor/phpunit/phpunit/phpunit
./phpqa tools
bin/ci.sh
./phpqa tools
if [[ ${CI_PHP_VERSION:0:3} == "7.4" ]]; then
./phpqa --config tests/.ci --tools "phpmetrics:0,phploc,phpcs:0,php-cs-fixer,phpmd:0,pdepend,phpcpd,phpstan,phpunit:0,psalm,security-checker,parallel-lint:0"
else
bin/ci.sh
fi
ls -lAh build
- name: Upload QA files
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"autoload-dev": {
"files": [
"tests/phpunit-compatibility.php",
"tests/.phpunit/fix-testcase.php",
"vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php"
]
},
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions tests/.phpunit/fix-typehints.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

$files = [
'OptionsTest.php',
'Report/ReportTest.php',
];
foreach ($files as $file) {
$path = __DIR__ . "/../{$file}";
$compatiblePhp = str_replace(
[
'function setUp()',
'function tearDown()',
],
[
'function setUp(): void',
'function tearDown(): void',
],
file_get_contents($path)
);
file_put_contents($path, $compatiblePhp);
}

0 comments on commit b0f1c6f

Please sign in to comment.