From ef57c1f88968b2723408dc1d2dcdf201101fe5b6 Mon Sep 17 00:00:00 2001 From: Vitalii Zhuk Date: Thu, 22 Feb 2024 16:11:26 +0200 Subject: [PATCH] Add consumer key to checker --- src/Command/RunConsumerCommand.php | 4 ++-- src/Consumer/Checker/RunConsumerCheckerInterface.php | 4 +++- tests/Unit/Command/RunConsumerCommandTest.php | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Command/RunConsumerCommand.php b/src/Command/RunConsumerCommand.php index b98c7f8..93c728d 100644 --- a/src/Command/RunConsumerCommand.php +++ b/src/Command/RunConsumerCommand.php @@ -88,14 +88,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($input->getOption('dry-run')) { $checker = $this->runCheckerRegistry->get($consumerKey); - $checker->checkBeforeRun(); + $checker->checkBeforeRun($consumerKey); return 0; } try { $checker = $this->runCheckerRegistry->get($consumerKey); - $checker->checkBeforeRun(); + $checker->checkBeforeRun($consumerKey); } catch (RunConsumerCheckerNotFoundException) { // Normal flow. Checker not found. } diff --git a/src/Consumer/Checker/RunConsumerCheckerInterface.php b/src/Consumer/Checker/RunConsumerCheckerInterface.php index 300865f..21809ba 100644 --- a/src/Consumer/Checker/RunConsumerCheckerInterface.php +++ b/src/Consumer/Checker/RunConsumerCheckerInterface.php @@ -23,7 +23,9 @@ interface RunConsumerCheckerInterface /** * Call to this method before run consumer. * + * @param string $consumer + * * @throws CannotRunConsumerException */ - public function checkBeforeRun(): void; + public function checkBeforeRun(string $consumer): void; } diff --git a/tests/Unit/Command/RunConsumerCommandTest.php b/tests/Unit/Command/RunConsumerCommandTest.php index 3afa391..3214baa 100644 --- a/tests/Unit/Command/RunConsumerCommandTest.php +++ b/tests/Unit/Command/RunConsumerCommandTest.php @@ -395,7 +395,9 @@ private function configureChecker(string $key, ?\Throwable $error): void { $checker = $this->createMock(RunConsumerCheckerInterface::class); - $matcher = $checker->expects(self::once())->method('checkBeforeRun'); + $matcher = $checker->expects(self::once()) + ->method('checkBeforeRun') + ->with($key); if ($error) { $matcher->willThrowException($error);