From 41e00a6933f3b642160323784271cb44856551e2 Mon Sep 17 00:00:00 2001 From: Okhin Date: Sat, 13 Oct 2018 14:10:56 +0200 Subject: [PATCH] Fixed the generic object test --- src/LQDN/CommandHandler.php | 6 +++++- tests/functional/Handler/CommandHandlerTest.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/LQDN/CommandHandler.php b/src/LQDN/CommandHandler.php index 11f5184..52eabda 100644 --- a/src/LQDN/CommandHandler.php +++ b/src/LQDN/CommandHandler.php @@ -19,7 +19,11 @@ class CommandHandler */ public function handle($command) { - $method = $this->getHandleMethod($command); + try { + $method = $this->getHandleMethod($command); + } catch (Exception $e) { + throw new CommandNotHandledException(); + } foreach ($this->handlers as $handler) { if (method_exists($handler, $method)) { diff --git a/tests/functional/Handler/CommandHandlerTest.php b/tests/functional/Handler/CommandHandlerTest.php index 7787060..4871cf1 100644 --- a/tests/functional/Handler/CommandHandlerTest.php +++ b/tests/functional/Handler/CommandHandlerTest.php @@ -16,7 +16,7 @@ class CommandHandlerTest extends Functionaltest public function testCommandNotHandledException() { $this->setExpectedException('LQDN\Exception\CommandNotHandledException'); - $this->container['command_handler']->handle(new Object()); + $this->container['command_handler']->handle(new class{}); } } -- GitLab