Skip to content

Commit 49bccdd

Browse files
committed
Merge remote-tracking branch '34232/improving-message-queue-error-message' into comm_78764_31355
2 parents dfe1548 + e52563f commit 49bccdd

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

lib/internal/Magento/Framework/MessageQueue/Test/Unit/Topology/Config/QueueConfigItem/DataMapperTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\MessageQueue\Rpc\ResponseQueueNameBuilder;
1515
use Magento\Framework\MessageQueue\Topology\Config\Data;
1616
use Magento\Framework\MessageQueue\Topology\Config\QueueConfigItem\DataMapper;
17+
use Magento\Framework\Phrase;
1718
use PHPUnit\Framework\MockObject\MockObject;
1819
use PHPUnit\Framework\TestCase;
1920

@@ -289,4 +290,46 @@ public function testGetMappedDataForWildcard(): void
289290
];
290291
$this->assertEquals($expectedResult, $actualResult);
291292
}
293+
294+
/**
295+
* @return void
296+
*/
297+
public function testTopicIsSynchronousException(): void
298+
{
299+
$topicName = 'topic01';
300+
$data = [
301+
'ex01' => [
302+
'name' => 'ex01',
303+
'type' => 'topic',
304+
'connection' => 'amqp',
305+
'durable' => true,
306+
'internal' => false,
307+
'autoDelete' => false,
308+
'arguments' => ['some' => 'argument'],
309+
'bindings' => [
310+
'bind01' => [
311+
'id' => 'bind01',
312+
'topic' => $topicName,
313+
'destinationType' => 'queue',
314+
'destination' => 'some.queue',
315+
'disabled' => false,
316+
'arguments' => ['some' => 'arguments'],
317+
],
318+
],
319+
],
320+
];
321+
322+
$this->communicationConfigMock->expects($this->exactly(1))
323+
->method('getTopic')
324+
->willThrowException(new LocalizedException(
325+
new Phrase('Topic "%topic" is not configured.', ['topic' => $topicName])
326+
));
327+
328+
$this->configDataMock->expects($this->once())->method('get')->willReturn($data);
329+
330+
$this->expectException(LocalizedException::class);
331+
$this->expectExceptionMessage(sprintf('Error while checking if topic "%s" is synchronous', $topicName));
332+
333+
$this->model->getMappedData();
334+
}
292335
}

lib/internal/Magento/Framework/MessageQueue/Topology/Config/QueueConfigItem/DataMapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ private function isSynchronousTopic(string $topicName): bool
145145
$topic = $this->communicationConfig->getTopic($topicName);
146146
return (bool)$topic[CommunicationConfig::TOPIC_IS_SYNCHRONOUS];
147147
} catch (LocalizedException $exception) {
148-
throw new LocalizedException(new Phrase('Error while checking if topic is synchronous'));
148+
throw new LocalizedException(
149+
new Phrase('Error while checking if topic "%topic" is synchronous', ['topic' => $topicName])
150+
);
149151
}
150152
}
151153

0 commit comments

Comments
 (0)