From 30b0eaf4d2ccbedf3977da40f1a31e200f69b614 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sat, 28 Feb 2026 17:11:07 +0100 Subject: [PATCH] replace phpunit by blackbox --- .gitattributes | 1 - .github/workflows/ci.yml | 32 ++++--------------------- .gitignore | 2 -- blackbox.php | 27 +++++++++++++++++++++ composer.json | 1 - phpunit.xml.dist | 22 ----------------- tests/Command/CheckDotInstalledTest.php | 20 ++++++++-------- tests/Command/DependsOnTest.php | 2 +- tests/Command/FromLockTest.php | 2 +- tests/Command/OfTest.php | 2 +- tests/Command/VendorTest.php | 2 +- tests/Loader/ComposerLockTest.php | 2 +- tests/Loader/DependenciesTest.php | 2 +- tests/Loader/Dependents/GraphTest.php | 2 +- tests/Loader/DependentsTest.php | 2 +- tests/Loader/PackageTest.php | 2 +- tests/Loader/VendorDependenciesTest.php | 2 +- tests/Loader/VendorTest.php | 2 +- tests/Package/ConstraintTest.php | 8 +++---- tests/Package/NameTest.php | 2 +- tests/Package/RelationTest.php | 2 +- tests/Package/VersionTest.php | 8 +++---- tests/PackageTest.php | 2 +- tests/RenderTest.php | 2 +- tests/Vendor/NameTest.php | 2 +- tests/VendorTest.php | 2 +- 26 files changed, 67 insertions(+), 88 deletions(-) create mode 100644 blackbox.php delete mode 100644 phpunit.xml.dist diff --git a/.gitattributes b/.gitattributes index 7d503af..1da7dcc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,4 @@ /.gitattributes export-ignore /.gitignore export-ignore -/phpunit.xml.dist export-ignore /fixtures export-ignore /tests export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f6e6d7..2f3eecb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,33 +3,11 @@ name: CI on: [push, pull_request] jobs: - phpunit: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macOS-latest] - php-version: ['8.4', '8.5'] - dependencies: ['lowest', 'highest'] - name: 'PHPUnit' - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - extensions: mbstring, intl - coverage: xdebug - ini-values: xdebug.max_nesting_level=2048 - - name: Composer - uses: "ramsey/composer-install@v3" - with: - dependency-versions: ${{ matrix.dependencies }} - - name: PHPUnit - run: vendor/bin/phpunit --coverage-clover=coverage.clover - - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} + blackbox: + uses: innmind/github-workflows/.github/workflows/black-box-matrix.yml@main + coverage: + uses: innmind/github-workflows/.github/workflows/coverage-matrix.yml@main + secrets: inherit psalm: uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: diff --git a/.gitignore b/.gitignore index 3285dca..ff72e2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ /composer.lock /vendor -.phpunit.result.cache -.phpunit.cache diff --git a/blackbox.php b/blackbox.php new file mode 100644 index 0000000..627d718 --- /dev/null +++ b/blackbox.php @@ -0,0 +1,27 @@ +when( + \getenv('ENABLE_COVERAGE') !== false, + static fn(Application $app) => $app + ->codeCoverage( + CodeCoverage::of( + __DIR__.'/src/', + __DIR__.'/tests/', + ) + ->dumpTo('coverage.clover') + ->enableWhen(true), + ) + ->scenariiPerProof(1), + ) + ->tryToProve(Load::directory(__DIR__.'/tests')) + ->exit(); diff --git a/composer.json b/composer.json index ed351d5..839632f 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,6 @@ } }, "require-dev": { - "phpunit/phpunit": "~12.0", "innmind/static-analysis": "~1.3", "innmind/black-box": "~6.5", "innmind/coding-standard": "~2.0" diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 034d8fd..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - ./tests - - - - - . - - - ./tests - ./vendor - - - diff --git a/tests/Command/CheckDotInstalledTest.php b/tests/Command/CheckDotInstalledTest.php index 1e53872..2ee8a3d 100644 --- a/tests/Command/CheckDotInstalledTest.php +++ b/tests/Command/CheckDotInstalledTest.php @@ -20,9 +20,9 @@ Str, Attempt, }; -use PHPUnit\Framework\TestCase; use Innmind\BlackBox\{ PHPUnit\BlackBox, + PHPUnit\Framework\TestCase, Set, }; @@ -30,11 +30,11 @@ class CheckDotInstalledTest extends TestCase { use BlackBox; - public function testCallCommandIfInstalled() + public function testCallCommandIfInstalled(): BlackBox\Proof { - $this + return $this ->forAll(Set::of('some', 'command', 'name')) - ->then(function($usage) { + ->prove(function($usage) { $inner = new class($usage) implements Command { public function __construct(private string $usage) { @@ -85,11 +85,11 @@ function($command) { }); } - public function testReturnErrorWhenNotInstalled() + public function testReturnErrorWhenNotInstalled(): BlackBox\Proof { - $this + return $this ->forAll(Set::of('some', 'command', 'name')) - ->then(function($usage) { + ->prove(function($usage) { $inner = new class($usage) implements Command { public function __construct(private string $usage) { @@ -149,11 +149,11 @@ function($command) { }); } - public function testUsage() + public function testUsage(): BlackBox\Proof { - $this + return $this ->forAll(Set::of('some', 'command', 'name')) - ->then(function($usage) { + ->prove(function($usage) { $inner = new class($usage) implements Command { public function __construct(private string $usage) { diff --git a/tests/Command/DependsOnTest.php b/tests/Command/DependsOnTest.php index 5248ffb..f91f17c 100644 --- a/tests/Command/DependsOnTest.php +++ b/tests/Command/DependsOnTest.php @@ -29,7 +29,7 @@ Map, Attempt, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class DependsOnTest extends TestCase { diff --git a/tests/Command/FromLockTest.php b/tests/Command/FromLockTest.php index 66adfb0..2f70199 100644 --- a/tests/Command/FromLockTest.php +++ b/tests/Command/FromLockTest.php @@ -26,7 +26,7 @@ Attempt, Map, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class FromLockTest extends TestCase { diff --git a/tests/Command/OfTest.php b/tests/Command/OfTest.php index 371015e..bcd536a 100644 --- a/tests/Command/OfTest.php +++ b/tests/Command/OfTest.php @@ -28,7 +28,7 @@ Map, Attempt, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class OfTest extends TestCase { diff --git a/tests/Command/VendorTest.php b/tests/Command/VendorTest.php index 10bc03c..552142d 100644 --- a/tests/Command/VendorTest.php +++ b/tests/Command/VendorTest.php @@ -29,7 +29,7 @@ Map, Attempt, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class VendorTest extends TestCase { diff --git a/tests/Loader/ComposerLockTest.php b/tests/Loader/ComposerLockTest.php index 2c51a38..3f1a8ae 100644 --- a/tests/Loader/ComposerLockTest.php +++ b/tests/Loader/ComposerLockTest.php @@ -10,7 +10,7 @@ use Innmind\OperatingSystem\Factory; use Innmind\Url\Path; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class ComposerLockTest extends TestCase { diff --git a/tests/Loader/DependenciesTest.php b/tests/Loader/DependenciesTest.php index 46d0e39..71204c4 100644 --- a/tests/Loader/DependenciesTest.php +++ b/tests/Loader/DependenciesTest.php @@ -12,7 +12,7 @@ use Innmind\HttpTransport\Transport; use Innmind\Time\Clock; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class DependenciesTest extends TestCase { diff --git a/tests/Loader/Dependents/GraphTest.php b/tests/Loader/Dependents/GraphTest.php index 1fdfdb9..88e2250 100644 --- a/tests/Loader/Dependents/GraphTest.php +++ b/tests/Loader/Dependents/GraphTest.php @@ -14,7 +14,7 @@ }; use Innmind\Url\Url; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class GraphTest extends TestCase { diff --git a/tests/Loader/DependentsTest.php b/tests/Loader/DependentsTest.php index a7b3c9e..4d14889 100644 --- a/tests/Loader/DependentsTest.php +++ b/tests/Loader/DependentsTest.php @@ -13,7 +13,7 @@ use Innmind\HttpTransport\Transport; use Innmind\Time\Clock; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class DependentsTest extends TestCase { diff --git a/tests/Loader/PackageTest.php b/tests/Loader/PackageTest.php index e3ff01e..e8f80ca 100644 --- a/tests/Loader/PackageTest.php +++ b/tests/Loader/PackageTest.php @@ -9,7 +9,7 @@ }; use Innmind\HttpTransport\Transport; use Innmind\Time\Clock; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class PackageTest extends TestCase { diff --git a/tests/Loader/VendorDependenciesTest.php b/tests/Loader/VendorDependenciesTest.php index 2100240..11f4f8d 100644 --- a/tests/Loader/VendorDependenciesTest.php +++ b/tests/Loader/VendorDependenciesTest.php @@ -12,7 +12,7 @@ use Innmind\HttpTransport\Transport; use Innmind\Time\Clock; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class VendorDependenciesTest extends TestCase { diff --git a/tests/Loader/VendorTest.php b/tests/Loader/VendorTest.php index 19cb490..df7b787 100644 --- a/tests/Loader/VendorTest.php +++ b/tests/Loader/VendorTest.php @@ -10,7 +10,7 @@ }; use Innmind\HttpTransport\Transport; use Innmind\Time\Clock; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class VendorTest extends TestCase { diff --git a/tests/Package/ConstraintTest.php b/tests/Package/ConstraintTest.php index ed116d2..0c07937 100644 --- a/tests/Package/ConstraintTest.php +++ b/tests/Package/ConstraintTest.php @@ -8,9 +8,9 @@ Package\Version, Exception\DomainException, }; -use PHPUnit\Framework\TestCase; use Innmind\BlackBox\{ PHPUnit\BlackBox, + PHPUnit\Framework\TestCase, Set, }; @@ -18,11 +18,11 @@ class ConstraintTest extends TestCase { use BlackBox; - public function testInterface() + public function testInterface(): BlackBox\Proof { - $this + return $this ->forAll(Set\Strings::any()->filter(static fn($string) => $string !== '')) - ->then(function(string $string): void { + ->prove(function(string $string): void { $this->assertSame($string, (new Constraint($string))->toString()); }); } diff --git a/tests/Package/NameTest.php b/tests/Package/NameTest.php index bbcdf7f..404d4d9 100644 --- a/tests/Package/NameTest.php +++ b/tests/Package/NameTest.php @@ -7,7 +7,7 @@ Package\Name, Exception\DomainException, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class NameTest extends TestCase { diff --git a/tests/Package/RelationTest.php b/tests/Package/RelationTest.php index 85a6d1e..a0d4a4f 100644 --- a/tests/Package/RelationTest.php +++ b/tests/Package/RelationTest.php @@ -8,7 +8,7 @@ Package\Constraint, Package\Name, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class RelationTest extends TestCase { diff --git a/tests/Package/VersionTest.php b/tests/Package/VersionTest.php index ea2782c..db1dc33 100644 --- a/tests/Package/VersionTest.php +++ b/tests/Package/VersionTest.php @@ -7,9 +7,9 @@ Package\Version, Exception\DomainException, }; -use PHPUnit\Framework\TestCase; use Innmind\BlackBox\{ PHPUnit\BlackBox, + PHPUnit\Framework\TestCase, Set, }; @@ -17,11 +17,11 @@ class VersionTest extends TestCase { use BlackBox; - public function testInterface() + public function testInterface(): BlackBox\Proof { - $this + return $this ->forAll(Set\Strings::any()->filter(static fn($string) => $string !== '')) - ->then(function(string $string): void { + ->prove(function(string $string): void { $this->assertSame($string, Version::of($string)->toString()); }); } diff --git a/tests/PackageTest.php b/tests/PackageTest.php index 002a184..1b82027 100644 --- a/tests/PackageTest.php +++ b/tests/PackageTest.php @@ -12,7 +12,7 @@ }; use Innmind\Url\Url; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class PackageTest extends TestCase { diff --git a/tests/RenderTest.php b/tests/RenderTest.php index f798a3f..a64fa16 100644 --- a/tests/RenderTest.php +++ b/tests/RenderTest.php @@ -16,7 +16,7 @@ Path, Scheme, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class RenderTest extends TestCase { diff --git a/tests/Vendor/NameTest.php b/tests/Vendor/NameTest.php index 7cea5ff..1263d93 100644 --- a/tests/Vendor/NameTest.php +++ b/tests/Vendor/NameTest.php @@ -7,7 +7,7 @@ Vendor\Name, Exception\DomainException, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class NameTest extends TestCase { diff --git a/tests/VendorTest.php b/tests/VendorTest.php index 823d295..3736ee2 100644 --- a/tests/VendorTest.php +++ b/tests/VendorTest.php @@ -13,7 +13,7 @@ }; use Innmind\Url\Url; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class VendorTest extends TestCase {