@@ -90,11 +90,24 @@ jobs:
9090 run : |
9191 if [ ! -d "vendor" ]; then
9292 echo "::warning::Composer vendor directory not found. Installing dependencies manually."
93- composer install --no-progress
93+ # For PHP 8.0+, we need to modify requirements or use ignore-platform-reqs
94+ if [[ "${{ matrix.php }}" == "8.0" || "${{ matrix.php }}" == "8.1" || "${{ matrix.php }}" == "8.2" ]]; then
95+ echo "::notice::Using PHP ${{ matrix.php }}, installing with --ignore-platform-reqs"
96+ composer install --no-progress --ignore-platform-reqs
97+ else
98+ composer install --no-progress
99+ fi
94100 fi
101+
95102 if [ ! -f "vendor/bin/phpunit" ]; then
96103 echo "::warning::PHPUnit not found in vendor/bin. Installing phpunit explicitly."
97- composer require phpunit/phpunit:^7.5 --dev --no-progress
104+ # For PHP 8.0+, we need a different PHPUnit version
105+ if [[ "${{ matrix.php }}" == "8.0" || "${{ matrix.php }}" == "8.1" || "${{ matrix.php }}" == "8.2" ]]; then
106+ echo "::notice::Using PHP ${{ matrix.php }}, installing PHPUnit 9.x"
107+ composer require --dev phpunit/phpunit:^9.0 --ignore-platform-reqs --no-progress
108+ else
109+ composer require --dev phpunit/phpunit:^7.5 --no-progress
110+ fi
98111 fi
99112
100113 - name : Check Test Environment
@@ -123,7 +136,18 @@ jobs:
123136 if : steps.check-test-env.outputs.test_env_ready == 'true'
124137 run : |
125138 if [ -f "vendor/bin/phpunit" ]; then
126- vendor/bin/phpunit
139+ # Handle WordPress compatibility with PHPUnit for PHP 8.0+
140+ if [[ "${{ matrix.php }}" == "8.0" || "${{ matrix.php }}" == "8.1" || "${{ matrix.php }}" == "8.2" ]]; then
141+ # Run with WordPress test compatibility parameter for newer PHPUnit versions
142+ echo "::notice::Running tests with PHPUnit 9.x compatibility mode for PHP ${{ matrix.php }}"
143+ vendor/bin/phpunit --no-deprecations || {
144+ echo "::warning::Test failed with --no-deprecations, trying with standard execution"
145+ vendor/bin/phpunit
146+ }
147+ else
148+ # PHP 7.x can use PHPUnit 7.x directly
149+ vendor/bin/phpunit
150+ fi
127151 else
128152 echo "::error::PHPUnit executable not found in vendor/bin directory."
129153 ls -la vendor/bin || echo "vendor/bin directory not found"
0 commit comments