Skip to content

Commit

Permalink
update illuminate/contracts to support ^11.0 (#19)
Browse files Browse the repository at this point in the history
* update illuminate/contracts to support ^11.0

* remove explicit require of dependencies

* add php 8.3 matrix

* revert laravel dependency removal

* update dependencies

* revert

* update tests

* debug

* update xml schema

* update exclude

* update port

* debug

* set DB_SOCKET

* set DB_URL

* revert

* enable xdebug

* enable xdebug coverage

* add phpunit dependency
  • Loading branch information
eithed authored Aug 15, 2024
1 parent 4d3c75a commit c7f1fa1
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 104 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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"
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
72 changes: 28 additions & 44 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,46 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Mannum Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_USERNAME" value=""/>
<env name="DB_PASSWORD" value=""/>
<env name="DB_DATABASE" value="zero_downtime_test_db"/>
<env name="DB_HOST" value="127.0.0.1"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Mannum Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_USERNAME" value=""/>
<env name="DB_PASSWORD" value=""/>
<env name="DB_DATABASE" value="zero_downtime_test_db"/>
<env name="DB_HOST" value="127.0.0.1"/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
6 changes: 2 additions & 4 deletions tests/Projectors/EloquentZeroDowntimeProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
30 changes: 10 additions & 20 deletions tests/ReplayManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
Expand All @@ -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();
Expand All @@ -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');
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();

Expand All @@ -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();

Expand Down
50 changes: 24 additions & 26 deletions tests/ReplaySerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c7f1fa1

Please sign in to comment.