diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4ad33fa..98163c2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -13,23 +13,29 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.0, 8.1, 8.2] - laravel: [9.*, 10.*] + php: [8.0, 8.1, 8.2, 8.3] + laravel: [9.*, 10.*, 11.*] stability: [prefer-lowest, prefer-stable] exclude: - php: 8.0 laravel: 10.* + - php: 8.0 + laravel: 11.* + - php: 8.1 + laravel: 11.* include: - laravel: 9.* testbench: ^7.0 - laravel: 10.* testbench: ^8.0 + - laravel: 11.* + testbench: ^9.2 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} services: postgres: - image: postgres:10.8 + image: postgres env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres @@ -51,8 +57,8 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - coverage: none + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, xdebug + coverage: xdebug - name: Setup problem matchers run: | @@ -61,10 +67,11 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit env: DATABASE_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres" + DB_URL: "postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres" diff --git a/composer.json b/composer.json index 2edd3e3..e9483b9 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,14 @@ ], "require": { "php": "^8.0", - "illuminate/contracts": "^9.45|^10.0", + "illuminate/contracts": "^9.45|^10.0|^11.0", "spatie/laravel-event-sourcing": "^6.0|^7.0", "spatie/laravel-package-tools": "^1.4.3" }, "require-dev": { - "nunomaduro/collision": "^6.0|^7.0", - "orchestra/testbench": "^7.0|^8.0", - "vimeo/psalm": "^4.8" + "nunomaduro/collision": "^6.0|^7.0|^8.0", + "orchestra/testbench": "^7.0|^8.0|^9.0", + "phpunit/phpunit": "^9.0|^10.0|^11.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d5526ff..d263cc3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,46 +1,30 @@ - - - - tests - - - - - ./src - - - - - - - - - - - - - - - - - + + + + tests + + + + + + + + + + + + + + + + + + + + + + ./src + + diff --git a/tests/Projectors/EloquentZeroDowntimeProjectorTest.php b/tests/Projectors/EloquentZeroDowntimeProjectorTest.php index d3e3e10..89eda8b 100644 --- a/tests/Projectors/EloquentZeroDowntimeProjectorTest.php +++ b/tests/Projectors/EloquentZeroDowntimeProjectorTest.php @@ -12,8 +12,7 @@ class EloquentZeroDowntimeProjectorTest extends TestCase { - /** @test */ - public function it_creates_new_tables_with_the_right_sequences_and_foreign_keys() + public function test_it_creates_new_tables_with_the_right_sequences_and_foreign_keys() { $projector = new PostProjector(); $projector->forReplay()->useConnection('foo'); @@ -39,8 +38,7 @@ public function it_creates_new_tables_with_the_right_sequences_and_foreign_keys( $this->assertEquals(1, $comment->id); } - /** @test */ - public function it_drops_table_and_sequences_on_removal() + public function test_it_drops_table_and_sequences_on_removal() { $projector = new PostProjector(); $projector->forReplay()->useConnection('foobar'); diff --git a/tests/ReplayManagerTest.php b/tests/ReplayManagerTest.php index db7f77b..31d723a 100644 --- a/tests/ReplayManagerTest.php +++ b/tests/ReplayManagerTest.php @@ -11,8 +11,7 @@ class ReplayManagerTest extends TestCase { - /** @test */ - public function it_throws_exception_when_replay_already_exists_on_start() + public function test_it_throws_exception_when_replay_already_exists_on_start() { $manager = new ReplayManager(new InMemoryReplayRepository(), new FakeProjectionist(), new FakeStoredEventRepository()); $manager->createReplay('foo', []); @@ -27,8 +26,7 @@ public function it_throws_exception_when_replay_already_exists_on_start() $this->assertTrue($thrown, "Exception StartReplayException expected but not thrown"); } - /** @test */ - public function it_validates_if_projector_is_configured() + public function test_it_validates_if_projector_is_configured() { $projectionist = new FakeProjectionist(); $repo = new InMemoryReplayRepository(); @@ -42,8 +40,7 @@ public function it_validates_if_projector_is_configured() $this->assertNull($repo->getReplayByKey('foo')); } - /** @test */ - public function it_persists_replay_with_valid_projectors() + public function test_it_persists_replay_with_valid_projectors() { $projectionist = new FakeProjectionist(); $projectionist->addProjector('RegisteredProjector'); @@ -59,8 +56,7 @@ public function it_persists_replay_with_valid_projectors() $this->assertEquals(['RegisteredProjector'], $replay->projectors); } - /** @test */ - public function it_starts_a_replay() + public function test_it_starts_a_replay() { $repo = new InMemoryReplayRepository(); $projectionist = new FakeProjectionist(); @@ -75,8 +71,7 @@ public function it_starts_a_replay() $this->assertEquals(0, $projectionist->replays[0]['startingFrom']); } - /** @test */ - public function it_starts_a_replay_from_last_projected_event() + public function test_it_starts_a_replay_from_last_projected_event() { $repo = new InMemoryReplayRepository(); $projectionist = new FakeProjectionist(); @@ -95,8 +90,7 @@ public function it_starts_a_replay_from_last_projected_event() $this->assertEquals(101, $projectionist->replays[0]['startingFrom']); } - /** @test */ - public function it_gets_replay_lag() + public function test_it_gets_replay_lag() { $repo = new InMemoryReplayRepository(); $projectionist = new FakeProjectionist(); @@ -113,8 +107,7 @@ public function it_gets_replay_lag() $this->assertEquals(44, $manager->getReplayLag('foo')); } - /** @test */ - public function it_enables_projections_when_lag_is_0() + public function test_it_enables_projections_when_lag_is_0() { $repo = new InMemoryReplayRepository(); $projectionist = new FakeProjectionist(); @@ -130,8 +123,7 @@ public function it_enables_projections_when_lag_is_0() $this->assertTrue($replay->projectionsEnabled); } - /** @test */ - public function it_does_not_enable_projections_when_lag_is_not_0() + public function test_it_does_not_enable_projections_when_lag_is_not_0() { $repo = new InMemoryReplayRepository(); $projectionist = new FakeProjectionist(); @@ -155,8 +147,7 @@ public function it_does_not_enable_projections_when_lag_is_not_0() $this->assertTrue($thrown, "exception not thrown"); } - /** @test */ - public function it_calls_projectors_to_put_replay_live() + public function test_it_calls_projectors_to_put_replay_live() { $projector = new FakeProjector(); @@ -174,8 +165,7 @@ public function it_calls_projectors_to_put_replay_live() $this->assertTrue($projector->hasBeenPutLive()); } - /** @test */ - public function it_can_remove_replays() + public function test_it_can_remove_replays() { $projector = new FakeProjector(); diff --git a/tests/ReplaySerializerTest.php b/tests/ReplaySerializerTest.php index 9a03ad0..8b6835c 100644 --- a/tests/ReplaySerializerTest.php +++ b/tests/ReplaySerializerTest.php @@ -8,82 +8,80 @@ class ReplaySerializerTest extends TestCase { - /** @test - * @dataProvider provider - */ - public function it_parses_and_reconstructs_plays(Replay $replay) + /** @dataProvider provider */ + public function test_it_parses_and_reconstructs_plays(Replay $replay) { $data = ReplaySerializer::toArray($replay); // Make sure array can be json encoded $data = json_decode(json_encode($data), true); $reconstructedReplay = ReplaySerializer::fromArray($data); - $this->assertEquals($replay, $reconstructedReplay); + self::assertEquals($replay, $reconstructedReplay); } - public function provider(): array + public static function provider(): array { return [ - [$this->replay()], - [$this->replayWithProjectors()], - [$this->startedReplay()], - [$this->replayInProgress()], - [$this->finishedReplay()], - [$this->twoReplays()], - [$this->enabledProjections()], + [self::replay()], + [self::replayWithProjectors()], + [self::startedReplay()], + [self::replayInProgress()], + [self::finishedReplay()], + [self::twoReplays()], + [self::enabledProjections()], ]; } - private function replay(): Replay + private static function replay(): Replay { return new Replay('foo'); } - private function replayWithProjectors(): Replay + private static function replayWithProjectors(): Replay { - $replay = $this->replay(); + $replay = self::replay(); $replay->addProjector('foobar'); $replay->addProjector('baz'); return $replay; } - private function startedReplay(): Replay + private static function startedReplay(): Replay { - $replay = $this->replayWithProjectors(); + $replay = self::replayWithProjectors(); $replay->started(0, Carbon::parse('2021-01-01 10:00:00')); return $replay; } - private function replayInProgress(): Replay + private static function replayInProgress(): Replay { - $replay = $this->startedReplay(); + $replay = self::startedReplay(); $replay->setLastProjectedEventNumber(10); return $replay; } - private function finishedReplay(): Replay + private static function finishedReplay(): Replay { - $replay = $this->replayInProgress(); + $replay = self::replayInProgress(); $replay->finished(Carbon::parse('2021-01-01 12:00:00')); return $replay; } - private function twoReplays(): Replay + private static function twoReplays(): Replay { - $replay = $this->finishedReplay(); + $replay = self::finishedReplay(); $replay->started(100, Carbon::parse('2021-01-02 14:00:00')); $replay->finished(Carbon::parse('2021-01-02 16:00:00')); return $replay; } - private function enabledProjections(): Replay + private static function enabledProjections(): Replay { - $replay = $this->replay(); + $replay = self::replay(); $replay->enableProjections(); return $replay;