Skip to content

Commit

Permalink
hack for phpunit 8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
troosan committed Feb 21, 2021
1 parent b71b4fd commit 2ae000c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,31 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Delete composer lock file
- name: Update PHPUnit version for PHP 8
id: composer-lock
if: "startsWith(matrix.php-version, '8.')"
run: |
rm -f composer.lock
echo "::set-output name=flags::--ignore-platform-reqs"
composer remove phpunit/phpunit --dev --no-update --no-interaction
composer require phpunit/phpunit ^8.0 --dev --no-update
- name: Install dependencies
run: composer update --no-progress --prefer-dist --optimize-autoloader ${{ steps.composer-lock.outputs.flags }}

- name: Update code to make PHPUnit 8 compatible
if: "startsWith(matrix.php-version, '8.')"
run: |
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUpBeforeClass()$/function setUpBeforeClass(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDownAfterClass()$/function tearDownAfterClass(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function setUp()$/function setUp(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/function tearDown()$/function tearDown(): void/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/->assertContains(/->assertStringContainsString(/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e 's/->assertNotContains(/->assertStringNotContainsString(/' {} \;
find ./tests/ -name "*.php" -type f -exec sed -i -e "s/->assertInternalType('array', /->assertIsArray(/" {} \;
sed -i "s/\$this->addWarning('The @expectedException,/\/\/\$this->addWarning('The @expectedException,/" ./vendor/phpunit/phpunit/src/Framework/TestCase.php
sed -i "s/self::createWarning('The optional \$delta/\/\/self::createWarning('The optional \$delta/" ./vendor/phpunit/phpunit/src/Framework/Assert.php
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

Expand All @@ -57,7 +72,7 @@ jobs:
uses: mheap/phpunit-matcher-action@v1

- name: Test with PHPUnit
run: ./vendor/bin/phpunit --teamcity -c ./
run: ./vendor/bin/phpunit --teamcity --no-coverage -c ./

php-cs-fixer:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 2ae000c

Please sign in to comment.