From 08a02ae64c260f04b1316d740656ebecb548110c Mon Sep 17 00:00:00 2001 From: Mateus Junges Date: Tue, 9 Jan 2024 17:24:15 -0300 Subject: [PATCH] Fix tests --- src/Console/Commands/ConsumerCommand.php | 15 ++++++++++++++- tests/Consumers/ConsumerTest.php | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Console/Commands/ConsumerCommand.php b/src/Console/Commands/ConsumerCommand.php index 5bb4f217..0991e2bd 100644 --- a/src/Console/Commands/ConsumerCommand.php +++ b/src/Console/Commands/ConsumerCommand.php @@ -57,7 +57,7 @@ public function handle() return; } - $parsedOptions = array_map(fn ($value) => $value === '?' ? null : $value, $this->options()); + $parsedOptions = array_map($this->parseOptions(...), $this->options()); $options = new Options($parsedOptions, $this->config); @@ -85,4 +85,17 @@ public function handle() $consumer->consume(); } + + private function parseOptions(int|string|null $option): int|string|null + { + if ($option === '?') { + return null; + } + + if (is_numeric($option)) { + return (int) $option; + } + + return $option; + } } diff --git a/tests/Consumers/ConsumerTest.php b/tests/Consumers/ConsumerTest.php index 192c27a6..805f00fa 100644 --- a/tests/Consumers/ConsumerTest.php +++ b/tests/Consumers/ConsumerTest.php @@ -317,7 +317,7 @@ public function testCanStopConsumeIfMaxTimeReached() $this->mockProducer(); $fakeHandler = new CallableConsumer( - function (KafkaConsumerMessage $message) { + function (ConsumerMessage $message) { sleep(2); }, []