32 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
34 $this->dataObjectEncoderMock = $this->getMockBuilder(\
Magento\Framework\Webapi\ServiceOutputProcessor::class)
35 ->disableOriginalConstructor()
38 $this->encoder = $this->objectManager->getObject(
39 MessageEncoder::class,
40 [
'dataObjectEncoder' => $this->dataObjectEncoderMock]
42 $this->communicationConfigMock = $this->getMockBuilder(CommunicationConfig::class)
43 ->disableOriginalConstructor()
45 $this->objectManager->setBackwardCompatibleProperty(
47 'communicationConfig',
48 $this->communicationConfigMock
59 $this->encoder->encode(
'customer.created',
'Some message');
68 $this->encoder->decode(
'customer.created',
'Some message');
77 $exceptionMessage =
'Message with topic "customer.created" must be an instance of "Magento\Customer\Api\Data"';
78 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn(
79 $this->getQueueConfigData()
81 $object = $this->getMockBuilder(\
Magento\Customer\Api\
Data\CustomerInterface::class)
82 ->disableOriginalConstructor()
85 $this->dataObjectEncoderMock
86 ->expects($this->once())
87 ->method(
'convertValue')
90 $this->encoder->encode(
'customer.created', $object);
99 $exceptionMessage =
'Message with topic "customer.created" must be an instance of "Magento\Customer\Api\Data"';
100 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn(
101 $this->getQueueConfigData()
103 $object = $this->getMockBuilder(\
Magento\Customer\Api\
Data\CustomerInterface::class)
104 ->disableOriginalConstructor()
107 $this->dataObjectEncoderMock
108 ->expects($this->once())
109 ->method(
'convertValue')
112 $this->encoder->encode(
'customer.created', [$object]);
120 private function getQueueConfigData()
123 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
124 CommunicationConfig::TOPIC_REQUEST => \Magento\Customer\Api\Data\CustomerInterface::class
testEncodeInvalidMessage()
testEncodeInvalidMessageArray()