diff --git a/tests/Integration/Projectionist/Aggregate/Profile.php b/tests/Integration/Projectionist/Aggregate/Profile.php index 64a4378a5..7c5599d62 100644 --- a/tests/Integration/Projectionist/Aggregate/Profile.php +++ b/tests/Integration/Projectionist/Aggregate/Profile.php @@ -11,6 +11,7 @@ use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer; use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Events\NameChanged; use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Events\ProfileCreated; +use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Events\Reborned; use Patchlevel\EventSourcing\Tests\Integration\Projectionist\ProfileId; #[Aggregate('profile')] @@ -34,6 +35,11 @@ public function changeName(string $name): void $this->recordThat(new NameChanged($name)); } + public function reborn(string $name): void + { + $this->recordThat(new Reborned($name)); + } + #[Apply] protected function applyProfileCreated(ProfileCreated $event): void { @@ -47,6 +53,12 @@ protected function applyNameChanged(NameChanged $event): void $this->name = $event->name; } + #[Apply] + protected function applyReborned(Reborned $event): void + { + $this->name = $event->name; + } + public function name(): string { return $this->name; diff --git a/tests/Integration/Projectionist/Events/Reborned.php b/tests/Integration/Projectionist/Events/Reborned.php new file mode 100644 index 000000000..2bbcb6acd --- /dev/null +++ b/tests/Integration/Projectionist/Events/Reborned.php @@ -0,0 +1,16 @@ +save($profile); } + + #[Subscribe(NameChanged::class)] + public function handleNameChanged(Message $message) + { + $id = ProfileId::fromString($message->aggregateId()); + + $repository = $this->repositoryManager->get(Profile::class); + + $profile = $repository->load($id); + + $profile->reborn('neo'); + + $repository->save($profile); + } } diff --git a/tests/Integration/Projectionist/ProjectionistTest.php b/tests/Integration/Projectionist/ProjectionistTest.php index 14929e37b..840cf35e6 100644 --- a/tests/Integration/Projectionist/ProjectionistTest.php +++ b/tests/Integration/Projectionist/ProjectionistTest.php @@ -28,7 +28,7 @@ use Patchlevel\EventSourcing\Store\DoctrineDbalStore; use Patchlevel\EventSourcing\Tests\DbalManager; use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Aggregate\Profile; -use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Projection\ChangeNameProcessor; +use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Projection\ProfileProcessor; use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Projection\ErrorProducerProjector; use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Projection\ProfileProjector; use PHPUnit\Framework\TestCase; @@ -323,7 +323,7 @@ public function testProcessor(): void $projectorAccessorRepository = new TraceableProjectorAccessorRepository( new MetadataProjectorAccessorRepository([ - new ChangeNameProcessor($manager) + new ProfileProcessor($manager) ]), $traceStack ); @@ -378,7 +378,7 @@ public function testProcessor(): void Projection::DEFAULT_GROUP, RunMode::FromBeginning, ProjectionStatus::Active, - 2, + 3, lastSavedAt: new DateTimeImmutable('2021-01-01T00:00:00'), ), ],