diff --git a/.gitattributes b/.gitattributes index 4160131..05f17e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,3 @@ /.gitattributes export-ignore /.gitignore export-ignore -/phpunit.xml.dist export-ignore /tests export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5820e81..180ee0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,33 +3,11 @@ name: CI on: [push] 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@v2" - with: - dependency-versions: ${{ matrix.dependencies }} - - name: PHPUnit - run: vendor/bin/phpunit --coverage-clover=coverage.clover - - uses: codecov/codecov-action@v3 - 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..50022e2 --- /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 b5f735a..0da8be9 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ } }, "require-dev": { - "phpunit/phpunit": "~10.2", "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/src/Agent/WatchFixtures.php b/src/Agent/WatchFixtures.php index 68c1bbd..8c9e73b 100644 --- a/src/Agent/WatchFixtures.php +++ b/src/Agent/WatchFixtures.php @@ -26,7 +26,7 @@ public function __invoke( return null; } - $filesystem->watch($fixtures)( + $_ = $filesystem->watch($fixtures)( $activities, static fn(Activities $activities, $continuation) => $continuation->continue( $activities->push(Activity::fixturesModified), diff --git a/src/Agent/WatchProofs.php b/src/Agent/WatchProofs.php index 3aa6c3d..fa82993 100644 --- a/src/Agent/WatchProofs.php +++ b/src/Agent/WatchProofs.php @@ -26,7 +26,7 @@ public function __invoke( return null; } - $filesystem->watch($proofs)( + $_ = $filesystem->watch($proofs)( $activities, static fn(Activities $activities, $continuation) => $continuation->continue( $activities->push(Activity::proofsModified), diff --git a/src/Agent/WatchProperties.php b/src/Agent/WatchProperties.php index 35ec509..6a42bf7 100644 --- a/src/Agent/WatchProperties.php +++ b/src/Agent/WatchProperties.php @@ -26,7 +26,7 @@ public function __invoke( return null; } - $filesystem->watch($properties)( + $_ = $filesystem->watch($properties)( $activities, static fn(Activities $activities, $continuation) => $continuation->continue( $activities->push(Activity::propertiesModified), diff --git a/src/Agent/WatchSources.php b/src/Agent/WatchSources.php index fa0b17b..aaa8f12 100644 --- a/src/Agent/WatchSources.php +++ b/src/Agent/WatchSources.php @@ -21,7 +21,7 @@ public function __invoke( ): ?Agent { $src = $project->resolve(Path::of('src/')); - $os->filesystem()->watch($src)( + $_ = $os->filesystem()->watch($src)( $activities, static fn(Activities $activities, $continuation) => $continuation->continue( $activities->push(Activity::sourcesModified), diff --git a/src/Agent/WatchTests.php b/src/Agent/WatchTests.php index f0b2dd7..57ca8ac 100644 --- a/src/Agent/WatchTests.php +++ b/src/Agent/WatchTests.php @@ -26,7 +26,7 @@ public function __invoke( return null; } - $filesystem->watch($tests)( + $_ = $filesystem->watch($tests)( $activities, static fn(Activities $activities, $continuation) => $continuation->continue( $activities->push(Activity::testsModified), diff --git a/tests/Agent/WatchFixturesTest.php b/tests/Agent/WatchFixturesTest.php index e4e8b75..b506701 100644 --- a/tests/Agent/WatchFixturesTest.php +++ b/tests/Agent/WatchFixturesTest.php @@ -20,6 +20,7 @@ Server, Server\Process\Builder, }; +use Innmind\Time\Halt; use Innmind\Filesystem\{ Adapter, Directory, @@ -28,8 +29,9 @@ use Innmind\Immutable\{ Set, Attempt, + SideEffect, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class WatchFixturesTest extends TestCase { @@ -66,11 +68,14 @@ static function($command) use (&$count) { return Attempt::result($builder->build()); }, + )) + ->haltProcessVia(Halt::via( + static fn() => Attempt::result(SideEffect::identity), )), ); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); @@ -92,7 +97,7 @@ public function testDoesntWatchWhenTheFolderDoesntExist() $os = OperatingSystem::new(); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); diff --git a/tests/Agent/WatchProofsTest.php b/tests/Agent/WatchProofsTest.php index 70d9601..e320dcf 100644 --- a/tests/Agent/WatchProofsTest.php +++ b/tests/Agent/WatchProofsTest.php @@ -20,6 +20,7 @@ Server, Server\Process\Builder, }; +use Innmind\Time\Halt; use Innmind\Filesystem\{ Adapter, Directory, @@ -28,8 +29,9 @@ use Innmind\Immutable\{ Set, Attempt, + SideEffect, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class WatchProofsTest extends TestCase { @@ -66,11 +68,14 @@ static function($command) use (&$count) { return Attempt::result($builder->build()); }, + )) + ->haltProcessVia(Halt::via( + static fn() => Attempt::result(SideEffect::identity), )), ); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); @@ -92,7 +97,7 @@ public function testDoesntWatchWhenTheFolderDoesntExist() $os = OperatingSystem::new(); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); diff --git a/tests/Agent/WatchPropertiesTest.php b/tests/Agent/WatchPropertiesTest.php index 7451d65..dbfe5bd 100644 --- a/tests/Agent/WatchPropertiesTest.php +++ b/tests/Agent/WatchPropertiesTest.php @@ -20,6 +20,7 @@ Server, Server\Process\Builder, }; +use Innmind\Time\Halt; use Innmind\Filesystem\{ Adapter, Directory, @@ -28,8 +29,9 @@ use Innmind\Immutable\{ Set, Attempt, + SideEffect, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class WatchPropertiesTest extends TestCase { @@ -66,11 +68,14 @@ static function($command) use (&$count) { return Attempt::result($builder->build()); }, + )) + ->haltProcessVia(Halt::via( + static fn() => Attempt::result(SideEffect::identity), )), ); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); @@ -92,7 +97,7 @@ public function testDoesntWatchWhenTheFolderDoesntExist() $os = OperatingSystem::new(); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); diff --git a/tests/Agent/WatchSourcesTest.php b/tests/Agent/WatchSourcesTest.php index c14b258..a0b1d75 100644 --- a/tests/Agent/WatchSourcesTest.php +++ b/tests/Agent/WatchSourcesTest.php @@ -20,6 +20,7 @@ Server, Server\Process\Builder, }; +use Innmind\Time\Halt; use Innmind\Filesystem\{ Adapter, Directory, @@ -28,8 +29,9 @@ use Innmind\Immutable\{ Set, Attempt, + SideEffect, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class WatchSourcesTest extends TestCase { @@ -66,11 +68,14 @@ static function($command) use (&$count) { return Attempt::result($builder->build()); }, + )) + ->haltProcessVia(Halt::via( + static fn() => Attempt::result(SideEffect::identity), )), ); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); diff --git a/tests/Agent/WatchTestsTest.php b/tests/Agent/WatchTestsTest.php index cade589..26a763c 100644 --- a/tests/Agent/WatchTestsTest.php +++ b/tests/Agent/WatchTestsTest.php @@ -20,6 +20,7 @@ Server, Server\Process\Builder, }; +use Innmind\Time\Halt; use Innmind\Filesystem\{ Adapter, Directory, @@ -28,8 +29,9 @@ use Innmind\Immutable\{ Set, Attempt, + SideEffect, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class WatchTestsTest extends TestCase { @@ -66,11 +68,14 @@ static function($command) use (&$count) { return Attempt::result($builder->build()); }, + )) + ->haltProcessVia(Halt::via( + static fn() => Attempt::result(SideEffect::identity), )), ); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); @@ -92,7 +97,7 @@ public function testDoesntWatchWhenTheFolderDoesntExist() $os = OperatingSystem::new(); $activities = Activities::new( - $this->createMock(Trigger::class), + new Trigger\All, new Iteration, Set::of(...Triggers::cases()), ); diff --git a/tests/BootstrapTest.php b/tests/BootstrapTest.php index 9ae4756..acde278 100644 --- a/tests/BootstrapTest.php +++ b/tests/BootstrapTest.php @@ -6,7 +6,7 @@ use function Innmind\LabStation\bootstrap; use Innmind\OperatingSystem\OperatingSystem; use Innmind\CLI\Commands; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class BootstrapTest extends TestCase { diff --git a/tests/Command/WorkTest.php b/tests/Command/WorkTest.php index 3c38c7f..8853995 100644 --- a/tests/Command/WorkTest.php +++ b/tests/Command/WorkTest.php @@ -11,7 +11,7 @@ }; use Innmind\CLI\Command; use Innmind\OperatingSystem\OperatingSystem; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class WorkTest extends TestCase { @@ -23,7 +23,7 @@ public function testInterface() new Monitor( OperatingSystem::new(), new Iteration, - $this->createMock(Trigger::class), + new Trigger\All, ), ), ); @@ -43,7 +43,7 @@ public function testUsage() new Monitor( OperatingSystem::new(), new Iteration, - $this->createMock(Trigger::class), + new Trigger\All, ), ))->usage()->toString(), ); diff --git a/tests/IterationTest.php b/tests/IterationTest.php index f030bec..0801e20 100644 --- a/tests/IterationTest.php +++ b/tests/IterationTest.php @@ -11,7 +11,7 @@ Command\Options, }; use Innmind\Immutable\Map; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class IterationTest extends TestCase { diff --git a/tests/Trigger/AllTest.php b/tests/Trigger/AllTest.php index 330c661..b4094f4 100644 --- a/tests/Trigger/AllTest.php +++ b/tests/Trigger/AllTest.php @@ -16,7 +16,7 @@ }; use Innmind\OperatingSystem\OperatingSystem; use Innmind\Immutable\Set; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class AllTest extends TestCase { @@ -28,9 +28,36 @@ public function testInterface() public function testTriggerAllSubTriggers() { $trigger = new All( - $trigger1 = $this->createMock(Trigger::class), - $trigger2 = $this->createMock(Trigger::class), - $trigger3 = $this->createMock(Trigger::class), + new class implements Trigger { + public function __invoke( + Console $console, + OperatingSystem $os, + Activity $activity, + Set $triggers, + ): Console { + return $console; + } + }, + new class implements Trigger { + public function __invoke( + Console $console, + OperatingSystem $os, + Activity $activity, + Set $triggers, + ): Console { + return $console; + } + }, + new class implements Trigger { + public function __invoke( + Console $console, + OperatingSystem $os, + Activity $activity, + Set $triggers, + ): Console { + return $console; + } + }, ); $triggers = Set::of(); $activity = Activity::start; @@ -46,21 +73,6 @@ public function testTriggerAllSubTriggers() new Options, ); $os = OperatingSystem::new(); - $trigger1 - ->expects($this->once()) - ->method('__invoke') - ->with($console, $os, $activity, $triggers) - ->willReturn($console); - $trigger2 - ->expects($this->once()) - ->method('__invoke') - ->with($console, $os, $activity, $triggers) - ->willReturn($console); - $trigger3 - ->expects($this->once()) - ->method('__invoke') - ->with($console, $os, $activity, $triggers) - ->willReturn($console); $this->assertSame($console, $trigger($console, $os, $activity, $triggers)); } diff --git a/tests/Trigger/BlackBoxTest.php b/tests/Trigger/BlackBoxTest.php index 9eacd04..284966a 100644 --- a/tests/Trigger/BlackBoxTest.php +++ b/tests/Trigger/BlackBoxTest.php @@ -35,9 +35,9 @@ Set as ISet, Attempt, }; -use PHPUnit\Framework\TestCase; use Innmind\BlackBox\{ PHPUnit\BlackBox as BB, + PHPUnit\Framework\TestCase, Set, }; @@ -78,11 +78,11 @@ public function testDoNothingWhenNotOfExpectedType() )); } - public function testDoNothingWhenTriggerNotEnabled() + public function testDoNothingWhenTriggerNotEnabled(): BB\Proof { - $this + return $this ->forAll(Set::of(...Activity::cases())) - ->then(function($type) { + ->prove(function($type) { $trigger = new BlackBox(new Iteration); $os = OperatingSystem::new(); @@ -115,16 +115,16 @@ public function testDoNothingWhenTriggerNotEnabled() }); } - public function testTriggerTestsSuiteWhenActivity() + public function testTriggerTestsSuiteWhenActivity(): BB\Proof { - $this + return $this ->forAll(Set::of( Activity::sourcesModified, Activity::proofsModified, Activity::fixturesModified, Activity::propertiesModified, )) - ->then(function($type) { + ->prove(function($type) { $trigger = new BlackBox( $iteration = new Iteration, ); @@ -204,16 +204,16 @@ function($command) use (&$count) { }); } - public function testDoesntTriggerWhenNoBlackBoxFile() + public function testDoesntTriggerWhenNoBlackBoxFile(): BB\Proof { - $this + return $this ->forAll(Set::of( Activity::sourcesModified, Activity::proofsModified, Activity::fixturesModified, Activity::propertiesModified, )) - ->then(function($type) { + ->prove(function($type) { $trigger = new BlackBox( $iteration = new Iteration, ); diff --git a/tests/Trigger/CodingStandardTest.php b/tests/Trigger/CodingStandardTest.php index f807339..c2dafad 100644 --- a/tests/Trigger/CodingStandardTest.php +++ b/tests/Trigger/CodingStandardTest.php @@ -34,9 +34,9 @@ Set, Attempt, }; -use PHPUnit\Framework\TestCase; use Innmind\BlackBox\{ PHPUnit\BlackBox, + PHPUnit\Framework\TestCase, Set as DataSet, }; @@ -142,9 +142,9 @@ public function testDoNothingWhenTriggerNotEnabled() ); } - public function testTriggerTestsSuiteWhenSourcesModified() + public function testTriggerTestsSuiteWhenSourcesModified(): BlackBox\Proof { - $this + return $this ->forAll(DataSet::of( Activity::sourcesModified, Activity::proofsModified, @@ -152,7 +152,7 @@ public function testTriggerTestsSuiteWhenSourcesModified() Activity::fixturesModified, Activity::propertiesModified, )) - ->then(function($activity) { + ->prove(function($activity) { $trigger = new CodingStandard( $iteration = new Iteration, ); diff --git a/tests/Trigger/ComposerUpdateTest.php b/tests/Trigger/ComposerUpdateTest.php index 044ec12..ea4b648 100644 --- a/tests/Trigger/ComposerUpdateTest.php +++ b/tests/Trigger/ComposerUpdateTest.php @@ -27,7 +27,7 @@ Set, Attempt, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class ComposerUpdateTest extends TestCase { diff --git a/tests/Trigger/DockerComposeTest.php b/tests/Trigger/DockerComposeTest.php index 4cd33a5..73fa632 100644 --- a/tests/Trigger/DockerComposeTest.php +++ b/tests/Trigger/DockerComposeTest.php @@ -32,7 +32,7 @@ Set, Attempt, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class DockerComposeTest extends TestCase { diff --git a/tests/Trigger/PsalmTest.php b/tests/Trigger/PsalmTest.php index da4b974..2c0dd80 100644 --- a/tests/Trigger/PsalmTest.php +++ b/tests/Trigger/PsalmTest.php @@ -34,7 +34,7 @@ Set, Attempt, }; -use PHPUnit\Framework\TestCase; +use Innmind\BlackBox\PHPUnit\Framework\TestCase; class PsalmTest extends TestCase { diff --git a/tests/Trigger/TestsTest.php b/tests/Trigger/TestsTest.php index 4110cc8..e2b3664 100644 --- a/tests/Trigger/TestsTest.php +++ b/tests/Trigger/TestsTest.php @@ -34,9 +34,9 @@ Set as ISet, Attempt, }; -use PHPUnit\Framework\TestCase; use Innmind\BlackBox\{ PHPUnit\BlackBox, + PHPUnit\Framework\TestCase, Set, }; @@ -78,11 +78,11 @@ public function testDoNothingWhenNotOfExpectedType() )); } - public function testDoNothingWhenTriggerNotEnabled() + public function testDoNothingWhenTriggerNotEnabled(): BlackBox\Proof { - $this + return $this ->forAll(Set::of(...Activity::cases())) - ->then(function($type) { + ->prove(function($type) { $trigger = new Tests(new Iteration); $os = OperatingSystem::new(); $console = Console::of( @@ -113,15 +113,15 @@ public function testDoNothingWhenTriggerNotEnabled() }); } - public function testTriggerTestsSuiteWhenActivity() + public function testTriggerTestsSuiteWhenActivity(): BlackBox\Proof { - $this + return $this ->forAll(Set::of( Activity::sourcesModified, Activity::testsModified, Activity::fixturesModified, )) - ->then(function($type) { + ->prove(function($type) { $trigger = new Tests( $iteration = new Iteration, ); @@ -200,15 +200,15 @@ function($command) use (&$count) { }); } - public function testDoesntTriggerWhenNoPHPUnitFile() + public function testDoesntTriggerWhenNoPHPUnitFile(): BlackBox\Proof { - $this + return $this ->forAll(Set::of( Activity::sourcesModified, Activity::testsModified, Activity::fixturesModified, )) - ->then(function($type) { + ->prove(function($type) { $trigger = new Tests( $iteration = new Iteration, );