Skip to content

Commit

Permalink
Merge pull request #10 from jgmullor/master
Browse files Browse the repository at this point in the history
Add Behat method to check if a message should not be dispatched
  • Loading branch information
jgmullor authored Jul 30, 2021
2 parents 26eebe7 + 07df06f commit 1266671
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions src/Behat/MessageValidatorOpenApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 not expected to be dispatched', $name));
}
}

private function checkSchemaFile($filename): void
{
if (false === is_file($filename)) {
Expand Down

0 comments on commit 1266671

Please sign in to comment.