From 193f0ff599d9894dafbc5e2423ee9737ccae37e2 Mon Sep 17 00:00:00 2001 From: Alex Bouma Date: Tue, 5 Nov 2024 11:19:50 +0100 Subject: [PATCH] Set phpunit/phpunit version when running tests --- .github/workflows/ci.yml | 27 +++++++++++++++------------ composer.json | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5efea0a2f..bd96d2695 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,14 +27,14 @@ jobs: - ubuntu-latest - windows-latest php: - - '7.2' - - '7.3' - - '7.4' - - '8.0' - - '8.1' - - '8.2' - - '8.3' - - '8.4' + - { version: '7.2', phpunit: '8.5.*' } + - { version: '7.3', phpunit: '9.6.*' } + - { version: '7.4', phpunit: '9.6.*' } + - { version: '8.0', phpunit: '9.6.*' } + - { version: '8.1', phpunit: '9.6.*' } + - { version: '8.2', phpunit: '9.6.*' } + - { version: '8.3', phpunit: '9.6.*' } + - { version: '8.4', phpunit: '9.6.*' } dependencies: - lowest - highest @@ -48,7 +48,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php }} + php-version: ${{ matrix.php.version }} coverage: xdebug - name: Setup Problem Matchers for PHPUnit @@ -63,13 +63,16 @@ jobs: uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.directory }} - key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.dependencies }}-composer- + key: ${{ runner.os }}-${{ matrix.php.version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-${{ matrix.php.version }}-${{ matrix.dependencies }}-composer- # These dependencies are not used running the tests but can cause deprecation warnings so we remove them before running the tests - name: Remove unused dependencies run: composer remove vimeo/psalm phpstan/phpstan friendsofphp/php-cs-fixer --dev --no-interaction --no-update + - name: Set phpunit/phpunit version constraint + run: composer require phpunit/phpunit:'${{ matrix.php.phpunit }}' --dev --no-interaction --no-update + - name: Install highest dependencies run: composer update --no-progress --no-interaction --prefer-dist if: ${{ matrix.dependencies == 'highest' }} @@ -89,4 +92,4 @@ jobs: - name: Check benchmarks run: vendor/bin/phpbench run --revs=1 --iterations=1 - if: ${{ matrix.dependencies == 'highest' && matrix.php == '8.2' }} + if: ${{ matrix.dependencies == 'highest' && matrix.php.version == '8.2' }} diff --git a/composer.json b/composer.json index ed9bc4792..0be4a6531 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ "monolog/monolog": "^1.6|^2.0|^3.0", "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^9.4", + "phpunit/phpunit": "^8.5|^9.6", "symfony/phpunit-bridge": "^5.2|^6.0|^7.0", "vimeo/psalm": "^4.17" },