Skip to content
This repository was archived by the owner on Aug 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.lock
.idea
.php-cs-fixer.cache
.phpunit.cache
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"php": "^8.2"
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
"phpunit/phpunit": "^11.5",
"broadway/coding-standard": "^1.2",
"phpstan/phpstan": "^2.0",
"phpspec/prophecy": "^1.15"
"phpspec/prophecy": "^1.15",
"phpspec/prophecy-phpunit": "^2.2"
},
"authors": [
{
Expand Down
42 changes: 16 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Test Suite">
<directory>./test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<phpunit backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite">
<directory>./test/</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
</exclude>
</groups>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</source>
</phpunit>
20 changes: 8 additions & 12 deletions test/EventSourcing/SnapshottingEventSourcingRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
use Broadway\Snapshotting\Snapshot\SnapshotRepository;
use Broadway\Snapshotting\Snapshot\Snapshotter;
use Broadway\Snapshotting\Snapshot\Trigger\EventCountTrigger;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

class SnapshottingEventSourcingRepositoryTest extends \PHPUnit\Framework\TestCase
{
use ProphecyTrait;

private $eventStore;
private $eventSourcingRepository;
private $snapshotRepository;
Expand All @@ -50,9 +54,7 @@ public function setUp(): void
);
}

/**
* @test
*/
#[Test]
public function it_reconstitutes_aggregate_when_no_snapshot_found()
{
$this->snapshotRepository
Expand All @@ -70,9 +72,7 @@ public function it_reconstitutes_aggregate_when_no_snapshot_found()
$this->snapshottingEventSourcingRepository->load(42);
}

/**
* @test
*/
#[Test]
public function it_queries_the_event_store_for_events_recorded_after_playhead_of_snapshot()
{
// create a snapshot of an aggregate root with 5 committed events
Expand Down Expand Up @@ -106,9 +106,7 @@ public function it_queries_the_event_store_for_events_recorded_after_playhead_of
$this->assertEquals(6, $aggregateRoot->getPlayhead());
}

/**
* @test
*/
#[Test]
public function it_does_not_take_a_snapshot_when_threshold_not_reached()
{
$aggregateRoot = $this->createAggregateRootWithEvents(99);
Expand All @@ -121,9 +119,7 @@ public function it_does_not_take_a_snapshot_when_threshold_not_reached()
$this->snapshottingEventSourcingRepository->save($aggregateRoot);
}

/**
* @test
*/
#[Test]
public function it_takes_a_snapshot_when_threshold_reached()
{
$aggregateRoot = $this->createAggregateRootWithEvents(100);
Expand Down
2 changes: 1 addition & 1 deletion test/Snapshot/InMemorySnapshotRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Broadway\Snapshotting\Snapshot;

class InMemorySnapshotRepositoryTest extends SnapshotRepositoryTest
class InMemorySnapshotRepositoryTest extends SnapshotRepositoryTestCase
{
/**
* @return SnapshotRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,28 @@
namespace Broadway\Snapshotting\Snapshot;

use Broadway\EventSourcing\EventSourcedAggregateRoot;
use PHPUnit\Framework\Attributes\Test;

abstract class SnapshotRepositoryTest extends \PHPUnit\Framework\TestCase
abstract class SnapshotRepositoryTestCase extends \PHPUnit\Framework\TestCase
{
/**
* @var SnapshotRepository
*/
protected $repository;

/**
* @test
*/
#[Test]
public function it_implements__snapshot_repository()
{
$this->assertInstanceOf(SnapshotRepository::class, $this->repository);
}

/**
* @test
*/
#[Test]
public function it_returns_null_when_no_snapshot_available()
{
$this->assertNull($this->repository->load(42));
}

/**
* @test
*/
#[Test]
public function it_returns_snapshot_when_available()
{
$aggregate = $this->createAggregateWithHistory(5);
Expand All @@ -51,9 +46,7 @@ public function it_returns_snapshot_when_available()
);
}

/**
* @test
*/
#[Test]
public function it_does_not_mutate_state_of__snapshot__aggregate_after_persisting()
{
$aggregate = $this->createAggregateWithHistory(5);
Expand All @@ -67,9 +60,7 @@ public function it_does_not_mutate_state_of__snapshot__aggregate_after_persistin
$this->assertEquals(new Snapshot($this->createAggregateWithHistory(5)), $snapshot);
}

/**
* @test
*/
#[Test]
public function it_does_not_mutate_state_of__snapshot__aggregate_after_loading()
{
$aggregate = $this->createAggregateWithHistory(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
use Broadway\CommandHandling\CommandBus;
use Broadway\EventSourcing\EventSourcedAggregateRoot;
use Broadway\Snapshotting\Snapshot\Command\ScheduleSnapshot;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\PhpUnit\ProphecyTrait;

class CommandDispatchingSnapshotterTest extends \PHPUnit\Framework\TestCase
{
use ProphecyTrait;

/**
* @var CommandBus
*/
Expand All @@ -28,9 +32,7 @@ class CommandDispatchingSnapshotterTest extends \PHPUnit\Framework\TestCase
*/
private $snapshotter;

/**
* @test
*/
#[Test]
public function it_dispatches__schedule_snapshot_command()
{
$this->commandBus
Expand Down
8 changes: 5 additions & 3 deletions test/Snapshot/Snapshotter/SynchronousSnapshotterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
use Broadway\EventSourcing\EventSourcedAggregateRoot;
use Broadway\Snapshotting\Snapshot\Snapshot;
use Broadway\Snapshotting\Snapshot\SnapshotRepository;
use PHPUnit\Framework\Attributes\Test;
use Prophecy\PhpUnit\ProphecyTrait;

class SynchronousSnapshotterTest extends \PHPUnit\Framework\TestCase
{
use ProphecyTrait;

/**
* @var SnapshotRepository
*/
Expand All @@ -28,9 +32,7 @@ class SynchronousSnapshotterTest extends \PHPUnit\Framework\TestCase
*/
private $snapshotter;

/**
* @test
*/
#[Test]
public function it_persists_directly_to__snapshot_repository()
{
$aggregate = new MyAggregate();
Expand Down
5 changes: 2 additions & 3 deletions test/Snapshot/Trigger/EventCountTriggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
namespace Broadway\Snapshotting\Snapshot\Trigger;

use Broadway\Snapshotting\EventSourcing\Testing\TestEventSourcedAggregateRoot;
use PHPUnit\Framework\Attributes\Test;

class EventCountTriggerTest extends \PHPUnit\Framework\TestCase
{
/**
* @test
*/
#[Test]
public function it_should_snapshot_when_number_of_uncommitted_events_exceeds_given_event_count()
{
$trigger = new EventCountTrigger(1);
Expand Down