From b9529ddd9ec5924bf4acda417ccfe8fe81d65ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gilberto=20Mullor?= Date: Sat, 12 Jun 2021 16:08:19 +0000 Subject: [PATCH 1/3] Add method to check if message should not be dispatched --- src/Behat/MessageValidatorOpenApiContext.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Behat/MessageValidatorOpenApiContext.php b/src/Behat/MessageValidatorOpenApiContext.php index c1197a4..d9d0557 100644 --- a/src/Behat/MessageValidatorOpenApiContext.php +++ b/src/Behat/MessageValidatorOpenApiContext.php @@ -85,6 +85,16 @@ public function theMessageShouldBeDispatchedManyTimes(string $name, int $times): } } + /** + * @Then the message :name should not be dispatched + */ + public function theMessageShouldNotBeDispatched(string $name): void + { + if (true === $this->spyMiddleware->hasMessage($name)) { + throw new \Exception(sprintf('Message %s was expected not to dispatch, actually dispatched', $name)); + } + } + private function checkSchemaFile($filename): void { if (false === is_file($filename)) { From ad5b69d25348f34123bbbef138af1a80f91a30ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gilberto=20Mullor?= Date: Sat, 12 Jun 2021 16:09:58 +0000 Subject: [PATCH 2/3] Add README --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6db2521..19e6520 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,11 @@ Check if message has dispatched: ```gherkin Then the message "pccomponentes.example.1.domain_event.resource.resource_created" should be dispatched ``` +Check if message has not been dispatched: +```gherkin +Then the message "pccomponentes.example.1.domain_event.resource.resource_created" should not be dispatched +``` + Configuration: ```yaml - PcComponentes\OpenApiMessagingContext\Behat\MessageValidatorOpenApiContext: From 07df06f9985095828fb53d4446aada5b2cb2a636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gilberto=20Mullor?= Date: Sat, 12 Jun 2021 16:17:48 +0000 Subject: [PATCH 3/3] Fix translation --- src/Behat/MessageValidatorOpenApiContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Behat/MessageValidatorOpenApiContext.php b/src/Behat/MessageValidatorOpenApiContext.php index d9d0557..e486160 100644 --- a/src/Behat/MessageValidatorOpenApiContext.php +++ b/src/Behat/MessageValidatorOpenApiContext.php @@ -91,7 +91,7 @@ public function theMessageShouldBeDispatchedManyTimes(string $name, int $times): public function theMessageShouldNotBeDispatched(string $name): void { if (true === $this->spyMiddleware->hasMessage($name)) { - throw new \Exception(sprintf('Message %s was expected not to dispatch, actually dispatched', $name)); + throw new \Exception(sprintf('Message %s was not expected to be dispatched', $name)); } }