Skip to content

Commit

Permalink
MessageValidator fails on hash arrays that dont have 0 element
Browse files Browse the repository at this point in the history
Magento\Framework\MessageQueue\Test\Unit\MessageValidatorTest::testInvalidMessageType with data set #11 (array('object_interface', 'Magento\Customer\Api\Data\Cus...face[]'), array(23, 545), 'Data in topic "topic" must be...e[]". ')
PHPUnit\Framework\Exception: Notice: Undefined offset: 0 in /magento/lib/internal/Magento/Framework/MessageQueue/MessageValidator.php:157.
  • Loading branch information
kandy committed Oct 16, 2020
1 parent dd862cd commit d0249ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function validatePrimitiveType($message, $messageType, $topic)
$realType = $this->getRealType($message);
if ($realType == 'array' && count($message) == 0) {
return;
} elseif ($realType == 'array' && count($message) > 0) {
} elseif ($realType == 'array' && isset($message[0])) {
$realType = $this->getRealType($message[0]);
$compareType = preg_replace('/\[\]/', '', $messageType);
}
Expand Down Expand Up @@ -153,7 +153,7 @@ protected function validateClassType($message, $messageType, $topic)
$realType = $this->getRealType($message);
if ($realType == 'array' && count($message) == 0) {
return;
} elseif ($realType == 'array' && count($message) > 0) {
} elseif ($realType == 'array' && isset($message[0])) {
$message = $message[0];
$compareType = preg_replace('/\[\]/', '', $messageType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,14 @@ public function getQueueConfigRequestType()
$customerMock,
'Data in topic "topic" must be of type "Magento\Customer\Api\Data\CustomerInterface[]". '
],
[
[
CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
CommunicationConfig::TOPIC_REQUEST => 'Magento\Customer\Api\Data\CustomerInterface[]'
],
[1=>23, 3=>545],
'Data in topic "topic" must be of type "Magento\Customer\Api\Data\CustomerInterface[]". '
],
];
}
}

0 comments on commit d0249ee

Please sign in to comment.