From b15379fcadfaa87ba47a7b0a657c9b340559d446 Mon Sep 17 00:00:00 2001 From: David Badura Date: Tue, 6 Feb 2024 12:24:10 +0100 Subject: [PATCH 1/3] extract consumer logic --- src/EventBus/Consumer.php | 10 ++ src/EventBus/DefaultConsumer.php | 46 +++++ src/EventBus/DefaultEventBus.php | 23 +-- src/Outbox/EventBusPublisher.php | 6 +- src/Outbox/OutboxEventBus.php | 11 ++ tests/Integration/Outbox/OutboxTest.php | 8 +- tests/Unit/EventBus/DefaultConsumerTest.php | 74 ++++++++ tests/Unit/EventBus/DefaultEventBusTest.php | 184 ++------------------ tests/Unit/Outbox/EventBusPublisherTest.php | 6 +- 9 files changed, 168 insertions(+), 200 deletions(-) create mode 100644 src/EventBus/Consumer.php create mode 100644 src/EventBus/DefaultConsumer.php create mode 100644 tests/Unit/EventBus/DefaultConsumerTest.php diff --git a/src/EventBus/Consumer.php b/src/EventBus/Consumer.php new file mode 100644 index 000000000..4d5a6cbd6 --- /dev/null +++ b/src/EventBus/Consumer.php @@ -0,0 +1,10 @@ +event()::class; + + $this->logger?->debug(sprintf( + 'EventBus: Consume message "%s".', + $eventClass, + )); + + $listeners = $this->listenerProvider->listenersForEvent($eventClass); + + foreach ($listeners as $listener) { + $this->logger?->info(sprintf( + 'EventBus: Listener "%s" consume message with event "%s".', + $listener->name(), + $eventClass, + )); + + ($listener->callable())($message); + } + } + + /** @param iterable $listeners */ + public static function create(iterable $listeners = []): self + { + return new self(new AttributeListenerProvider($listeners)); + } +} diff --git a/src/EventBus/DefaultEventBus.php b/src/EventBus/DefaultEventBus.php index 9c0d39f48..887cea36e 100644 --- a/src/EventBus/DefaultEventBus.php +++ b/src/EventBus/DefaultEventBus.php @@ -16,7 +16,7 @@ final class DefaultEventBus implements EventBus private bool $processing; public function __construct( - private readonly ListenerProvider $listenerProvider, + private readonly Consumer $consumer, private readonly LoggerInterface|null $logger = null, ) { $this->queue = []; @@ -46,24 +46,7 @@ public function dispatch(Message ...$messages): void $this->logger?->debug('EventBus: Start processing queue.'); while ($message = array_shift($this->queue)) { - $eventClass = $message->event()::class; - - $this->logger?->debug(sprintf( - 'EventBus: Dispatch message "%s" to listeners.', - $eventClass, - )); - - $listeners = $this->listenerProvider->listenersForEvent($eventClass); - - foreach ($listeners as $listener) { - $this->logger?->info(sprintf( - 'EventBus: Dispatch message with event "%s" to listener "%s".', - $eventClass, - $listener->name(), - )); - - ($listener->callable())($message); - } + $this->consumer->consume($message); } } finally { $this->processing = false; @@ -75,6 +58,6 @@ public function dispatch(Message ...$messages): void /** @param iterable $listeners */ public static function create(iterable $listeners = []): self { - return new self(new AttributeListenerProvider($listeners)); + return new self(DefaultConsumer::create($listeners)); } } diff --git a/src/Outbox/EventBusPublisher.php b/src/Outbox/EventBusPublisher.php index 964707657..1c8781b50 100644 --- a/src/Outbox/EventBusPublisher.php +++ b/src/Outbox/EventBusPublisher.php @@ -4,18 +4,18 @@ namespace Patchlevel\EventSourcing\Outbox; -use Patchlevel\EventSourcing\EventBus\EventBus; +use Patchlevel\EventSourcing\EventBus\Consumer; use Patchlevel\EventSourcing\EventBus\Message; final class EventBusPublisher implements OutboxPublisher { public function __construct( - private readonly EventBus $eventBus, + private readonly Consumer $consumer, ) { } public function publish(Message $message): void { - $this->eventBus->dispatch($message); + $this->consumer->consume($message); } } diff --git a/src/Outbox/OutboxEventBus.php b/src/Outbox/OutboxEventBus.php index 6d388358a..ea751eb81 100644 --- a/src/Outbox/OutboxEventBus.php +++ b/src/Outbox/OutboxEventBus.php @@ -6,16 +6,27 @@ use Patchlevel\EventSourcing\EventBus\EventBus; use Patchlevel\EventSourcing\EventBus\Message; +use Psr\Log\LoggerInterface; + +use function sprintf; final class OutboxEventBus implements EventBus { public function __construct( private readonly OutboxStore $store, + private readonly LoggerInterface|null $logger = null, ) { } public function dispatch(Message ...$messages): void { $this->store->saveOutboxMessage(...$messages); + + foreach ($messages as $message) { + $this->logger?->debug(sprintf( + 'EventBus: Message "%s" added to queue.', + $message->event()::class, + )); + } } } diff --git a/tests/Integration/Outbox/OutboxTest.php b/tests/Integration/Outbox/OutboxTest.php index 5616743d5..baacc3923 100644 --- a/tests/Integration/Outbox/OutboxTest.php +++ b/tests/Integration/Outbox/OutboxTest.php @@ -5,7 +5,7 @@ namespace Patchlevel\EventSourcing\Tests\Integration\Outbox; use Doctrine\DBAL\Connection; -use Patchlevel\EventSourcing\EventBus\DefaultEventBus; +use Patchlevel\EventSourcing\EventBus\DefaultConsumer; use Patchlevel\EventSourcing\Outbox\DoctrineOutboxStore; use Patchlevel\EventSourcing\Outbox\EventBusPublisher; use Patchlevel\EventSourcing\Outbox\OutboxEventBus; @@ -74,9 +74,7 @@ public function testSuccessful(): void $projectorRepository, ); - $realEventBus = DefaultEventBus::create([ - new SendEmailProcessor(), - ]); + $eventBusConsumer = DefaultConsumer::create([new SendEmailProcessor()]); $eventStream = new SyncProjectionistEventBusWrapper( $outboxEventBus, @@ -120,7 +118,7 @@ public function testSuccessful(): void $consumer = new StoreOutboxConsumer( $outboxStore, - new EventBusPublisher($realEventBus), + new EventBusPublisher($eventBusConsumer), ); $consumer->consume(); diff --git a/tests/Unit/EventBus/DefaultConsumerTest.php b/tests/Unit/EventBus/DefaultConsumerTest.php new file mode 100644 index 000000000..e2fc23a8a --- /dev/null +++ b/tests/Unit/EventBus/DefaultConsumerTest.php @@ -0,0 +1,74 @@ +message = $message; + } + }; + + $message = new Message( + new ProfileCreated( + ProfileId::fromString('1'), + Email::fromString('info@patchlevel.de'), + ), + ); + + $provider = $this->prophesize(ListenerProvider::class); + $provider->listenersForEvent(ProfileCreated::class)->willReturn([new ListenerDescriptor($listener->__invoke(...))]); + + $eventBus = new DefaultConsumer($provider->reveal()); + $eventBus->consume($message); + + self::assertSame($message, $listener->message); + } + + public function testConsumeWithSubscribe(): void + { + $listener = new class { + public Message|null $message = null; + + #[Subscribe(ProfileCreated::class)] + public function __invoke(Message $message): void + { + $this->message = $message; + } + }; + + $message = new Message( + new ProfileCreated( + ProfileId::fromString('1'), + Email::fromString('info@patchlevel.de'), + ), + ); + + $eventBus = DefaultConsumer::create([$listener]); + $eventBus->consume($message); + + self::assertSame($message, $listener->message); + } +} diff --git a/tests/Unit/EventBus/DefaultEventBusTest.php b/tests/Unit/EventBus/DefaultEventBusTest.php index e8d213b4c..e3396f0d2 100644 --- a/tests/Unit/EventBus/DefaultEventBusTest.php +++ b/tests/Unit/EventBus/DefaultEventBusTest.php @@ -4,10 +4,8 @@ namespace Patchlevel\EventSourcing\Tests\Unit\EventBus; -use Patchlevel\EventSourcing\Attribute\Subscribe; +use Patchlevel\EventSourcing\EventBus\Consumer; use Patchlevel\EventSourcing\EventBus\DefaultEventBus; -use Patchlevel\EventSourcing\EventBus\ListenerDescriptor; -use Patchlevel\EventSourcing\EventBus\ListenerProvider; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Tests\Unit\Fixture\Email; use Patchlevel\EventSourcing\Tests\Unit\Fixture\NameChanged; @@ -17,8 +15,6 @@ use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; -use function microtime; - /** @covers \Patchlevel\EventSourcing\EventBus\DefaultEventBus */ final class DefaultEventBusTest extends TestCase { @@ -26,15 +22,6 @@ final class DefaultEventBusTest extends TestCase public function testDispatchEvent(): void { - $listener = new class { - public Message|null $message = null; - - public function __invoke(Message $message): void - { - $this->message = $message; - } - }; - $message = new Message( new ProfileCreated( ProfileId::fromString('1'), @@ -42,52 +29,15 @@ public function __invoke(Message $message): void ), ); - $provider = $this->prophesize(ListenerProvider::class); - $provider->listenersForEvent(ProfileCreated::class)->willReturn([new ListenerDescriptor($listener->__invoke(...))]); - - $eventBus = new DefaultEventBus($provider->reveal()); - $eventBus->dispatch($message); - - self::assertSame($message, $listener->message); - } - - public function testDispatchEventWithSubscribe(): void - { - $listener = new class { - public Message|null $message = null; - - #[Subscribe(ProfileCreated::class)] - public function __invoke(Message $message): void - { - $this->message = $message; - } - }; - - $message = new Message( - new ProfileCreated( - ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de'), - ), - ); + $consumer = $this->prophesize(Consumer::class); + $consumer->consume($message)->shouldBeCalled(); - $eventBus = DefaultEventBus::create([$listener]); + $eventBus = new DefaultEventBus($consumer->reveal()); $eventBus->dispatch($message); - - self::assertSame($message, $listener->message); } public function testDispatchMultipleMessages(): void { - $listener = new class { - /** @var list */ - public array $message = []; - - public function __invoke(Message $message): void - { - $this->message[] = $message; - } - }; - $message1 = new Message( new ProfileCreated( ProfileId::fromString('1'), @@ -102,79 +52,12 @@ public function __invoke(Message $message): void ), ); - $provider = $this->prophesize(ListenerProvider::class); - $provider->listenersForEvent(ProfileCreated::class)->willReturn([new ListenerDescriptor($listener->__invoke(...))]); - $provider->listenersForEvent(ProfileCreated::class)->willReturn([new ListenerDescriptor($listener->__invoke(...))]); + $consumer = $this->prophesize(Consumer::class); + $consumer->consume($message1)->shouldBeCalled(); + $consumer->consume($message2)->shouldBeCalled(); - $eventBus = new DefaultEventBus($provider->reveal()); + $eventBus = new DefaultEventBus($consumer->reveal()); $eventBus->dispatch($message1, $message2); - - self::assertCount(2, $listener->message); - self::assertSame($message1, $listener->message[0]); - self::assertSame($message2, $listener->message[1]); - } - - public function testSynchroneEvents(): void - { - $messageA = new Message( - new ProfileCreated( - ProfileId::fromString('1'), - Email::fromString('info@patchlevel.de'), - ), - ); - - $messageB = new Message( - new ProfileVisited( - ProfileId::fromString('1'), - ), - ); - - $provider = $this->prophesize(ListenerProvider::class); - $eventBus = new DefaultEventBus($provider->reveal()); - - $listenerA = new class ($eventBus, $messageB) { - public float|null $time = null; - - public function __construct( - private DefaultEventBus $bus, - private Message $message, - ) { - } - - public function __invoke(Message $message): void - { - if (!$message->event() instanceof ProfileCreated) { - return; - } - - $this->bus->dispatch($this->message); - - $this->time = microtime(true); - } - }; - - $listenerB = new class { - public float|null $time = null; - - public function __invoke(Message $message): void - { - if (!$message->event() instanceof ProfileVisited) { - return; - } - - $this->time = microtime(true); - } - }; - - $provider->listenersForEvent(ProfileCreated::class)->willReturn([new ListenerDescriptor($listenerA->__invoke(...))]); - $provider->listenersForEvent(ProfileVisited::class)->willReturn([new ListenerDescriptor($listenerB->__invoke(...))]); - - $eventBus->dispatch($messageA); - - self::assertNotNull($listenerA->time); - self::assertNotNull($listenerB->time); - - self::assertTrue($listenerA->time < $listenerB->time); } public function testMultipleMessagesAddingNewEventInListener(): void @@ -198,52 +81,15 @@ public function testMultipleMessagesAddingNewEventInListener(): void ), ); - $provider = $this->prophesize(ListenerProvider::class); - $eventBus = new DefaultEventBus($provider->reveal()); - - $listenerA = new class ($eventBus, $messageC) { - public float|null $time = null; - - public function __construct( - private DefaultEventBus $bus, - private Message $message, - ) { - } - - public function __invoke(Message $message): void - { - if (!$message->event() instanceof ProfileCreated) { - return; - } + $consumer = $this->prophesize(Consumer::class); + $eventBus = new DefaultEventBus($consumer->reveal()); - $this->bus->dispatch($this->message); - - $this->time = microtime(true); - } - }; - - $listenerB = new class { - public float|null $time = null; - - public function __invoke(Message $message): void - { - if (!$message->event() instanceof NameChanged) { - return; - } - - $this->time = microtime(true); - } - }; - - $provider->listenersForEvent(ProfileCreated::class)->willReturn([new ListenerDescriptor($listenerA->__invoke(...))]); - $provider->listenersForEvent(ProfileVisited::class)->willReturn([]); - $provider->listenersForEvent(NameChanged::class)->willReturn([new ListenerDescriptor($listenerB->__invoke(...))]); + $consumer->consume($messageA)->shouldBeCalled()->will(static function () use ($eventBus, $messageC): void { + $eventBus->dispatch($messageC); + }); + $consumer->consume($messageB)->shouldBeCalled(); + $consumer->consume($messageC)->shouldBeCalled(); $eventBus->dispatch($messageA, $messageB); - - self::assertNotNull($listenerA->time); - self::assertNotNull($listenerB->time); - - self::assertTrue($listenerA->time < $listenerB->time); } } diff --git a/tests/Unit/Outbox/EventBusPublisherTest.php b/tests/Unit/Outbox/EventBusPublisherTest.php index 9c6fc82f6..13961e20f 100644 --- a/tests/Unit/Outbox/EventBusPublisherTest.php +++ b/tests/Unit/Outbox/EventBusPublisherTest.php @@ -4,7 +4,7 @@ namespace Patchlevel\EventSourcing\Tests\Unit\Outbox; -use Patchlevel\EventSourcing\EventBus\EventBus; +use Patchlevel\EventSourcing\EventBus\Consumer; use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Outbox\EventBusPublisher; use Patchlevel\EventSourcing\Tests\Unit\Fixture\Email; @@ -27,8 +27,8 @@ public function testPublish(): void ), ); - $eventBus = $this->prophesize(EventBus::class); - $eventBus->dispatch($message)->shouldBeCalled(); + $eventBus = $this->prophesize(Consumer::class); + $eventBus->consume($message)->shouldBeCalled(); $publisher = new EventBusPublisher($eventBus->reveal()); $publisher->publish($message); From 6111a01c481326029f44b85e73aba1ea0a4e0d27 Mon Sep 17 00:00:00 2001 From: David Badura Date: Tue, 6 Feb 2024 12:44:04 +0100 Subject: [PATCH 2/3] update docs --- docs/pages/event_bus.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/pages/event_bus.md b/docs/pages/event_bus.md index bd3178430..f7b36def7 100644 --- a/docs/pages/event_bus.md +++ b/docs/pages/event_bus.md @@ -84,12 +84,31 @@ $eventBus = DefaultEventBus::create([ The order in which the listeners are executed is determined by the order in which they are passed to the factory. +Internally, the event bus uses the `Consumer` to consume the messages and call the listeners. + +## Consumer + +The consumer is responsible for consuming the messages and calling the listeners. + +```php +use Patchlevel\EventSourcing\EventBus\DefaultConsumer; + +$consumer = DefaultConsumer::create([ + $mailListener, +]; + +$consumer->consume($message); +``` + +Internally, the consumer uses the `ListenerProvider` to find the listeners for the message. + ## Listener provider The listener provider is responsible for finding all listeners for a specific event. The default listener provider uses attributes to find the listeners. ```php +use Patchlevel\EventSourcing\EventBus\DefaultConsumer; use Patchlevel\EventSourcing\EventBus\DefaultEventBus; use Patchlevel\EventSourcing\EventBus\AttributeListenerProvider; @@ -97,12 +116,14 @@ $listenerProvider = new AttributeListenerProvider([ $mailListener, ]); -$eventBus = new DefaultEventBus($listenerProvider); +$eventBus = new DefaultEventBus( + new DefaultConsumer($listenerProvider) +); ``` !!! tip - The `DefaultEventBus::create` method uses the `AttributeListenerProvider` by default. + The `DefaultEventBus::create` method uses the `DefaultConsumer` and `AttributeListenerProvider` by default. ### Custom listener provider From b366f7e321261f8d27e6c9d3d70575dd6a2a3d7c Mon Sep 17 00:00:00 2001 From: David Badura Date: Tue, 6 Feb 2024 12:49:25 +0100 Subject: [PATCH 3/3] rename outbox consumer into processor --- docs/pages/outbox.md | 17 +++++++++++------ src/Console/Command/OutboxConsumeCommand.php | 6 +++--- src/Outbox/OutboxConsumer.php | 10 ---------- src/Outbox/OutboxProcessor.php | 10 ++++++++++ ...boxConsumer.php => StoreOutboxProcessor.php} | 4 ++-- tests/Integration/Outbox/OutboxTest.php | 6 +++--- .../Command/OutboxConsumeCommandTest.php | 10 +++++----- tests/Unit/Outbox/StoreOutboxConsumerTest.php | 12 ++++++------ 8 files changed, 40 insertions(+), 35 deletions(-) delete mode 100644 src/Outbox/OutboxConsumer.php create mode 100644 src/Outbox/OutboxProcessor.php rename src/Outbox/{StoreOutboxConsumer.php => StoreOutboxProcessor.php} (79%) diff --git a/docs/pages/outbox.md b/docs/pages/outbox.md index 9d0a848c1..4404a538d 100644 --- a/docs/pages/outbox.md +++ b/docs/pages/outbox.md @@ -23,12 +23,12 @@ This stores the events to be dispatched in the database. use Patchlevel\EventSourcing\Repository\DefaultRepositoryManager; use Patchlevel\EventSourcing\Outbox\OutboxEventBus; -$outboxEventBus = new OutboxEventBus($store); +$eventBus = new OutboxEventBus($store); $repositoryManager = new DefaultRepositoryManager( $aggregateRootRegistry, $store, - $outboxEventBus + $eventBus ); ``` @@ -36,15 +36,20 @@ And then you have to define the consumer. This gets the right event bus. It is used to load the events to be dispatched from the database, dispatch the events and then empty the outbox table. ```php +use Patchlevel\EventSourcing\EventBus\DefaultConsumer; use Patchlevel\EventSourcing\Outbox\EventBusPublisher; -use Patchlevel\EventSourcing\Outbox\StoreOutboxConsumer; +use Patchlevel\EventSourcing\Outbox\StoreOutboxProcessor; -$consumer = new StoreOutboxConsumer( +$consumer = DefaultConsumer::create([ + $mailListener, +]); + +$processor = new StoreOutboxProcessor( $store, - new EventBusPublisher($realEventBus) + new EventBusPublisher($consumer) ); -$consumer->consume(); +$processor->process(); ``` ## Using outbox diff --git a/src/Console/Command/OutboxConsumeCommand.php b/src/Console/Command/OutboxConsumeCommand.php index 33a0c0ae9..484ac68a8 100644 --- a/src/Console/Command/OutboxConsumeCommand.php +++ b/src/Console/Command/OutboxConsumeCommand.php @@ -5,7 +5,7 @@ namespace Patchlevel\EventSourcing\Console\Command; use Patchlevel\EventSourcing\Console\InputHelper; -use Patchlevel\EventSourcing\Outbox\OutboxConsumer; +use Patchlevel\EventSourcing\Outbox\OutboxProcessor; use Patchlevel\Worker\DefaultWorker; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -21,7 +21,7 @@ final class OutboxConsumeCommand extends Command { public function __construct( - private readonly OutboxConsumer $consumer, + private readonly OutboxProcessor $processor, ) { parent::__construct(); } @@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $worker = DefaultWorker::create( function () use ($messageLimit): void { - $this->consumer->consume($messageLimit); + $this->processor->process($messageLimit); }, [ 'runLimit' => $runLimit, diff --git a/src/Outbox/OutboxConsumer.php b/src/Outbox/OutboxConsumer.php deleted file mode 100644 index 3642bd919..000000000 --- a/src/Outbox/OutboxConsumer.php +++ /dev/null @@ -1,10 +0,0 @@ -store->retrieveOutboxMessages($limit); diff --git a/tests/Integration/Outbox/OutboxTest.php b/tests/Integration/Outbox/OutboxTest.php index baacc3923..5781abcd6 100644 --- a/tests/Integration/Outbox/OutboxTest.php +++ b/tests/Integration/Outbox/OutboxTest.php @@ -9,7 +9,7 @@ use Patchlevel\EventSourcing\Outbox\DoctrineOutboxStore; use Patchlevel\EventSourcing\Outbox\EventBusPublisher; use Patchlevel\EventSourcing\Outbox\OutboxEventBus; -use Patchlevel\EventSourcing\Outbox\StoreOutboxConsumer; +use Patchlevel\EventSourcing\Outbox\StoreOutboxProcessor; use Patchlevel\EventSourcing\Projection\Projection\ProjectionCriteria; use Patchlevel\EventSourcing\Projection\Projection\Store\InMemoryStore; use Patchlevel\EventSourcing\Projection\Projectionist\DefaultProjectionist; @@ -116,12 +116,12 @@ public function testSuccessful(): void $message->event(), ); - $consumer = new StoreOutboxConsumer( + $consumer = new StoreOutboxProcessor( $outboxStore, new EventBusPublisher($eventBusConsumer), ); - $consumer->consume(); + $consumer->process(); self::assertSame(0, $outboxStore->countOutboxMessages()); self::assertCount(0, $outboxStore->retrieveOutboxMessages()); diff --git a/tests/Unit/Console/Command/OutboxConsumeCommandTest.php b/tests/Unit/Console/Command/OutboxConsumeCommandTest.php index 03e2f4abe..67be7b31d 100644 --- a/tests/Unit/Console/Command/OutboxConsumeCommandTest.php +++ b/tests/Unit/Console/Command/OutboxConsumeCommandTest.php @@ -5,7 +5,7 @@ namespace Patchlevel\EventSourcing\Tests\Unit\Console\Command; use Patchlevel\EventSourcing\Console\Command\OutboxConsumeCommand; -use Patchlevel\EventSourcing\Outbox\OutboxConsumer; +use Patchlevel\EventSourcing\Outbox\OutboxProcessor; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Input\ArrayInput; @@ -18,8 +18,8 @@ final class OutboxConsumeCommandTest extends TestCase public function testSuccessful(): void { - $consumer = $this->prophesize(OutboxConsumer::class); - $consumer->consume(100)->shouldBeCalled(); + $consumer = $this->prophesize(OutboxProcessor::class); + $consumer->process(100)->shouldBeCalled(); $command = new OutboxConsumeCommand( $consumer->reveal(), @@ -35,8 +35,8 @@ public function testSuccessful(): void public function testSuccessfulWithAllLimits(): void { - $consumer = $this->prophesize(OutboxConsumer::class); - $consumer->consume(200)->shouldBeCalled(); + $consumer = $this->prophesize(OutboxProcessor::class); + $consumer->process(200)->shouldBeCalled(); $command = new OutboxConsumeCommand( $consumer->reveal(), diff --git a/tests/Unit/Outbox/StoreOutboxConsumerTest.php b/tests/Unit/Outbox/StoreOutboxConsumerTest.php index 925591fbe..70a3262b1 100644 --- a/tests/Unit/Outbox/StoreOutboxConsumerTest.php +++ b/tests/Unit/Outbox/StoreOutboxConsumerTest.php @@ -7,14 +7,14 @@ use Patchlevel\EventSourcing\EventBus\Message; use Patchlevel\EventSourcing\Outbox\OutboxPublisher; use Patchlevel\EventSourcing\Outbox\OutboxStore; -use Patchlevel\EventSourcing\Outbox\StoreOutboxConsumer; +use Patchlevel\EventSourcing\Outbox\StoreOutboxProcessor; use Patchlevel\EventSourcing\Tests\Unit\Fixture\Email; use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileCreated; use Patchlevel\EventSourcing\Tests\Unit\Fixture\ProfileId; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; -/** @covers \Patchlevel\EventSourcing\Outbox\StoreOutboxConsumer */ +/** @covers \Patchlevel\EventSourcing\Outbox\StoreOutboxProcessor */ final class StoreOutboxConsumerTest extends TestCase { use ProphecyTrait; @@ -35,8 +35,8 @@ public function testConsume(): void $eventBus = $this->prophesize(OutboxPublisher::class); $eventBus->publish($message)->shouldBeCalled(); - $consumer = new StoreOutboxConsumer($store->reveal(), $eventBus->reveal()); - $consumer->consume(); + $consumer = new StoreOutboxProcessor($store->reveal(), $eventBus->reveal()); + $consumer->process(); } public function testConsumeWithLimit(): void @@ -55,7 +55,7 @@ public function testConsumeWithLimit(): void $eventBus = $this->prophesize(OutboxPublisher::class); $eventBus->publish($message)->shouldBeCalled(); - $consumer = new StoreOutboxConsumer($store->reveal(), $eventBus->reveal()); - $consumer->consume(100); + $consumer = new StoreOutboxProcessor($store->reveal(), $eventBus->reveal()); + $consumer->process(100); } }