diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index cec01ce..ae62b5a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -11,7 +11,7 @@ on:
jobs:
tests:
- name: PHP ${{ matrix.php-version }} on ${{ matrix.os }} (${{ matrix.composer-options }})
+ name: PHP ${{ matrix.php-version }} PHPUnit ${{matrix.phpunit-version}} on ${{ matrix.os }} (${{ matrix.prefer-lowest }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -25,9 +25,34 @@ jobs:
- ubuntu-latest
- windows-latest
- macOS-latest
- composer-options:
+ phpunit-version:
+ - "10"
+ - "11"
+ - "12"
+ prefer-lowest:
- ""
- "--prefer-lowest"
+ exclude:
+ # PHPUnit ^11 requires PHP 8.2
+ - phpunit-version: "11"
+ php-version: "8.1"
+
+ # PHPUnit ^12 requires PHP 8.3
+ - phpunit-version: "12"
+ php-version: "8.1"
+ - phpunit-version: "12"
+ php-version: "8.2"
+ include:
+ # PHPUnit ^10.5.32 is incompatible with paratest 7.3.
+ # Paratest 7.4.6, which fixes the incompatibility, requires PHP 8.2
+ - php-version: "8.1"
+ phpunit-version: "10"
+ update-constraints: "'--with=phpunit/phpunit:<10.5.32'"
+
+ # PHPUnit ~11.0 || ~11.1 can't double readonly classes, which fails some tests
+ # We constraint PHPUnit 11 to ^11.2 until we find a better solution
+ - phpunit-version: "11"
+ update-constraints: "'--with=phpunit/phpunit:^11.2'"
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -44,23 +69,32 @@ jobs:
run: composer validate
- name: Install dependencies
- run: composer update
- --prefer-dist
- --no-progress
- ${{ matrix.composer-options }}
+ run: >
+ composer update --prefer-dist --no-progress
+ ${{ matrix.prefer-lowest }}
+ '--with=phpunit/phpunit:^${{ matrix.phpunit-version }}'
+ ${{ matrix.update-constraints }}
+ shell: bash
+
+ - name: Set PHPUnit version
+ id: set-phpunit-version
+ run: |
+ echo "Tested against PHPUnit **v$(composer print-phpunit-version)**" >> "$GITHUB_STEP_SUMMARY"
+ echo "PHPUNIT_SCHEMA_VERSION=$(composer print-phpunit-schema-version)" >> "$GITHUB_OUTPUT"
+ shell: bash
- name: Run tests
- if: ${{ matrix.os != 'windows-latest' && !contains(matrix.composer-options, '--prefer-lowest') }}
+ if: ${{ matrix.os != 'windows-latest' && steps.set-phpunit-version.outputs.PHPUNIT_SCHEMA_VERSION != '10.0' }}
run: composer test
- - name: Run tests (lowest)
- if: ${{ matrix.os != 'windows-latest' && contains(matrix.composer-options, '--prefer-lowest') }}
- run: composer test-lowest
+ - name: Run tests (phpunit10.0)
+ if: ${{ matrix.os != 'windows-latest' && steps.set-phpunit-version.outputs.PHPUNIT_SCHEMA_VERSION == '10.0' }}
+ run: composer test-phpunit10.0
- name: Run tests (windows)
- if: ${{ matrix.os == 'windows-latest' && !contains(matrix.composer-options, '--prefer-lowest') }}
+ if: ${{ matrix.os == 'windows-latest' && steps.set-phpunit-version.outputs.PHPUNIT_SCHEMA_VERSION != '10.0' }}
run: composer test-windows
- - name: Run tests (windows-lowest)
- if: ${{ matrix.os == 'windows-latest' && contains(matrix.composer-options, '--prefer-lowest') }}
- run: composer test-windows-lowest
+ - name: Run tests (windows-phpunit10.0)
+ if: ${{ matrix.os == 'windows-latest' && steps.set-phpunit-version.outputs.PHPUNIT_SCHEMA_VERSION == '10.0' }}
+ run: composer test-windows-phpunit10.0
diff --git a/composer.json b/composer.json
index 5e60897..5e2c29a 100644
--- a/composer.json
+++ b/composer.json
@@ -31,14 +31,13 @@
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"allure-framework/allure-php-commons": "^2.0",
- "phpunit/phpunit": "^10 || ^11 || ^12"
+ "phpunit/phpunit": "^10.0.5 || ^11 || ^12.0.1"
},
"require-dev": {
- "phpunit/phpunit": "~10.4.0 || ^11 || ^12",
- "brianium/paratest": "^7.3",
- "psalm/plugin-phpunit": "^0.19.3",
+ "brianium/paratest": "^7",
+ "psalm/plugin-phpunit": "^0.19.5",
"squizlabs/php_codesniffer": "^3.7.2",
- "vimeo/psalm": "^6.9"
+ "vimeo/psalm": "^6.10"
},
"conflict": {
"amphp/byte-stream": "<1.5.1",
@@ -63,20 +62,21 @@
},
"psr-4": {
"Qameta\\Allure\\PHPUnit\\Test\\Unit\\": "test/unit/",
- "Qameta\\Allure\\PHPUnit\\Test\\Report\\": "test/report/"
+ "Qameta\\Allure\\PHPUnit\\Test\\Report\\": "test/report/",
+ "Qameta\\Allure\\PHPUnit\\Scripts\\": "scripts/"
}
},
"scripts": {
"test-cs": "vendor/bin/phpcs -sp",
"test-unit": "vendor/bin/phpunit --coverage-text",
- "test-unit-lowest": "vendor/bin/phpunit --configuration=phpunit.10.0.xml --coverage-text",
+ "test-unit-phpunit10.0": "vendor/bin/phpunit --configuration=phpunit.10.0.xml --coverage-text",
"clear-allure-results": "rm -rf ./build/allure-results",
"test-report": [
"@clear-allure-results",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=positive",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative; exit 0"
],
- "test-report-lowest": [
+ "test-report-phpunit10.0": [
"@clear-allure-results",
"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=positive",
"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=negative; exit 0"
@@ -86,7 +86,7 @@
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=positive",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative & exit 0"
],
- "test-report-windows-lowest": [
+ "test-report-windows-phpunit10.0": [
"@clear-allure-results",
"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=positive",
"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=negative & exit 0"
@@ -98,10 +98,10 @@
"@test-report",
"@test-psalm"
],
- "test-lowest": [
+ "test-phpunit10.0": [
"@test-cs",
- "@test-unit-lowest",
- "@test-report-lowest",
+ "@test-unit-phpunit10.0",
+ "@test-report-phpunit10.0",
"@test-psalm"
],
"test-windows": [
@@ -110,11 +110,17 @@
"@test-report-windows",
"@test-psalm"
],
- "test-windows-lowest": [
+ "test-windows-phpunit10.0": [
"@test-cs",
- "@test-unit-lowest",
- "@test-report-windows-lowest",
+ "@test-unit-phpunit10.0",
+ "@test-report-windows-phpunit10.0",
"@test-psalm"
+ ],
+ "print-phpunit-version": [
+ "Qameta\\Allure\\PHPUnit\\Scripts\\CiScripts::printPhpUnitVersion"
+ ],
+ "print-phpunit-schema-version": [
+ "Qameta\\Allure\\PHPUnit\\Scripts\\CiScripts::printConfigSchemaVersion"
]
}
}
diff --git a/phpunit.10.0.xml b/phpunit.10.0.xml
index b392ed1..f312c7e 100644
--- a/phpunit.10.0.xml
+++ b/phpunit.10.0.xml
@@ -1,7 +1,7 @@
test/unit/
-
+
src/
-
+
diff --git a/phpunit.report.xml b/phpunit.report.xml
index 3f527f7..7619e6c 100644
--- a/phpunit.report.xml
+++ b/phpunit.report.xml
@@ -1,7 +1,7 @@
self::assertSame($x, $y));
}
+ /**
+ * @return iterable>
+ */
public static function providerNamed(): iterable
{
return [
@@ -34,6 +37,9 @@ public function testListedDataSet(int $x, int $y): void
Allure::runStep(fn () => self::assertSame($x, $y));
}
+ /**
+ * @return iterable>
+ */
public static function providerListed(): iterable
{
return [
diff --git a/test/unit/Event/EventTestTrait.php b/test/unit/Event/EventTestTrait.php
index 9a31f40..5557fd0 100644
--- a/test/unit/Event/EventTestTrait.php
+++ b/test/unit/Event/EventTestTrait.php
@@ -38,26 +38,7 @@ trait EventTestTrait
{
protected function createTelemetryInfo(): Info
{
- /**
- * @psalm-suppress MixedAssignment
- * @psalm-suppress TooManyArguments
- */
- $garbageCollectorStatus = class_exists(GarbageCollectorStatus::class)
- ? new GarbageCollectorStatus(
- 0,
- 0,
- 0,
- 0,
- 0.0,
- 0.0,
- 0.0,
- 0.0,
- false,
- false,
- false,
- 0,
- )
- : null; // early PHPUnit 10
+ $garbageCollectorStatus = self::createGarbageCollectorStatus();
/**
* @psalm-suppress TooManyArguments
@@ -264,4 +245,51 @@ protected function createTestWarningTriggeredEvent(
false,
);
}
+
+ /**
+ * GarbageCollectorStatus doesn't exist in PHPUnit 10.0
+ * @psalm-suppress UndefinedClass
+ */
+ private static function createGarbageCollectorStatus(): ?GarbageCollectorStatus
+ {
+ // GarbageCollectorStatus doesn't exist in PHPUnit 10.0
+ if (class_exists(GarbageCollectorStatus::class)) {
+ $ctorInfo = (new \ReflectionClass(GarbageCollectorStatus::class))->getConstructor();
+ if (isset($ctorInfo)) {
+ /**
+ * @psalm-suppress InvalidArgument
+ * @psalm-suppress TooFewArguments
+ * @psalm-suppress TooManyArguments
+ */
+ return $ctorInfo->getNumberOfParameters() === 8
+ # PHPUnit [10.1, 10.3)
+ ? new GarbageCollectorStatus(
+ 0,
+ 0,
+ 0,
+ 0,
+ false,
+ false,
+ false,
+ 0,
+ )
+ # Extra arguments are required since 10.3.0
+ : new GarbageCollectorStatus(
+ 0,
+ 0,
+ 0,
+ 0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ false,
+ false,
+ false,
+ 0,
+ );
+ }
+ }
+ return null;
+ }
}
diff --git a/test/unit/ExceptionDetailsTraitTest.php b/test/unit/ExceptionDetailsTraitTest.php
index 2f17db0..2c3c1e9 100644
--- a/test/unit/ExceptionDetailsTraitTest.php
+++ b/test/unit/ExceptionDetailsTraitTest.php
@@ -4,16 +4,18 @@
namespace Qameta\Allure\PHPUnit\Test\Unit;
+// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
+
use Exception;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\CoversTrait;
use Qameta\Allure\PHPUnit\ExceptionDetailsTrait;
use Qameta\Allure\PHPUnit\AllureAdapter;
use Qameta\Allure\PHPUnit\AllureAdapterInterface;
use Throwable;
-// #[CoversTrait(ExceptionDetailsTrait::class)] <--- needed by phpunit 12
-// #[CoversClass(ExceptionDetailsTrait::class)] <--- needed by phpunit 10 + 11
-final class ExceptionDetailsTraitTest extends TestCase
+abstract class ExceptionDetailsTraitTestBase extends TestCase
{
public function testOnNotSuccessfulTest_GivenException_ThrowsSameException(): void
{
@@ -49,3 +51,22 @@ public function testOnNotSuccessfulTest_GivenException_SetsSameExceptionAsLast()
}
}
}
+
+/**
+ * CoversTrait was added in PHPUnit 11.2.0.
+ * If was then deprecated in 11.4.0 but the deprecation was reverted in 11.5.4.
+ * @psalm-suppress DeprecatedClass
+ */
+if (class_exists(CoversTrait::class)) {
+ #[CoversTrait(ExceptionDetailsTrait::class)]
+ final class ExceptionDetailsTraitTest extends ExceptionDetailsTraitTestBase
+ {
+ }
+
+} else {
+ #[CoversClass(ExceptionDetailsTrait::class)]
+ final class ExceptionDetailsTraitTest extends ExceptionDetailsTraitTestBase
+ {
+ }
+
+}