diff --git a/tests/Integration/Service/MessageDispatcherManagerTest.php b/tests/Integration/Service/MessageDispatcherManagerTest.php new file mode 100644 index 0000000..5d29603 --- /dev/null +++ b/tests/Integration/Service/MessageDispatcherManagerTest.php @@ -0,0 +1,39 @@ +get(MessageDispatcherManagerInterface::class); + $this->assertEquals($message, $manager->dispatch($description)); + } + + public function testMissingDispatcher(): void + { + self::bootKernel(); + + $container = static::getContainer(); + $manager = $container->get(MessageDispatcherManagerInterface::class); + + $description = 'no dispatcher'; + + $this->expectException(NoDispatcherForMessageException::class); + $this->expectExceptionMessage(sprintf("No dispatcher for description '%s'.", $description)); + + $manager->dispatch($description); + } +} diff --git a/tests/Integration/Service/StateHandlerManagerTest.php b/tests/Integration/Service/StateHandlerManagerTest.php new file mode 100644 index 0000000..0c21b32 --- /dev/null +++ b/tests/Integration/Service/StateHandlerManagerTest.php @@ -0,0 +1,44 @@ + 123])])] + #[TestWith(['required state', Action::TEARDOWN, null])] + public function testHandle(string $state, Action $action, ?StateValues $stateValues): void + { + self::bootKernel(); + + $container = static::getContainer(); + + $manager = $container->get(StateHandlerManagerInterface::class); + $this->assertEquals($stateValues, $manager->handle($state, $action, ['key' => 'value'])); + } + + #[TestWith([Action::SETUP])] + #[TestWith([Action::TEARDOWN])] + public function testMissingHandler(Action $action): void + { + self::bootKernel(); + + $container = static::getContainer(); + $manager = $container->get(StateHandlerManagerInterface::class); + + $state = 'no handler'; + + $this->expectException(NoHandlerForStateException::class); + $this->expectExceptionMessage(sprintf("No handler for state '%s'.", $state)); + + $manager->handle($state, $action, ['key' => 'value']); + } +} diff --git a/tests/Unit/Service/MessageDispatcherManagerTest.php b/tests/Unit/Service/MessageDispatcherManagerTest.php index 50dfd74..15192b9 100644 --- a/tests/Unit/Service/MessageDispatcherManagerTest.php +++ b/tests/Unit/Service/MessageDispatcherManagerTest.php @@ -27,7 +27,7 @@ protected function setUp(): void public function testNoHandler(): void { - $description = 'no handler'; + $description = 'no dispatcher'; $this->locator ->expects($this->once()) ->method('has')