Skip to content

Commit

Permalink
fix(PLT-4441): update thrown errors
Browse files Browse the repository at this point in the history
  • Loading branch information
IiiigorGG committed Aug 12, 2021
1 parent 8927de7 commit 9a75f81
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"symfony/messenger": "^4.4 || ^5.0",
"behat/behat": "^3.0",
"symfony/serializer": "^5.0"
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<ruleset name="Platform-Mail-Service-Api">
<description>The coding standard of Platform-Mail-Service-Api package</description>
<description>The coding standard of MessengerBehatContext package</description>
<arg value="p" />

<config name="ignore_warnings_on_exit" value="1" />
Expand Down
10 changes: 8 additions & 2 deletions src/Context/MessengerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ public function busShouldContainMessageWithJson(string $busName, PyStringNode $e
$expectedMessage = $this->decodeExpectedJson($expectedMessage);

$transport = $this->getMessengerTransportByName($busName);
$actualMessageList = [];
foreach ($transport->get() as $envelope) {
$actualMessage = $this->convertToArray($envelope->getMessage());
if ($this->isArraysSimilar($actualMessage, $expectedMessage)) {
return;
}

$actualMessageList[] = $actualMessage;
}

throw new Exception(
sprintf(
'The transport doesn\'t contain message with JSON: %s',
'The transport doesn\'t contain message with such JSON, actual messages: %s',
$this->getPrettyJson($expectedMessage)
)
);
Expand All @@ -62,16 +65,19 @@ public function busShouldContainMessageWithJsonAndVariableFields(
$expectedMessage = $this->decodeExpectedJson($expectedMessage);

$transport = $this->getMessengerTransportByName($busName);
$actualMessageList = [];
foreach ($transport->get() as $envelope) {
$actualMessage = $this->convertToArray($envelope->getMessage());
if ($this->isArraysSimilar($actualMessage, $expectedMessage, $variableFields)) {
return;
}

$actualMessageList[] = $actualMessage;
}

throw new Exception(
sprintf(
'The transport doesn\'t contain message with JSON: %s',
'The transport doesn\'t contain message with such JSON, actual messages: %s',
$this->getPrettyJson($expectedMessage)
)
);
Expand Down

0 comments on commit 9a75f81

Please sign in to comment.