9 use Doctrine\Instantiator\Exception\InvalidArgumentException;
27 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
30 $this->communicationConfigMock = $this->getMockBuilder(CommunicationConfig::class)
31 ->disableOriginalConstructor()
35 'communicationConfig',
36 $this->communicationConfigMock
46 $this->model->validate(
'customer.created',
'Some message',
true);
51 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn(
52 $this->getQueueConfigDataObjectType()
54 $object = $this->getMockBuilder(\
Magento\Customer\Api\
Data\CustomerInterface::class)
55 ->disableOriginalConstructor()
59 $this->model->validate(
'customer.created', $object,
true);
64 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn(
65 $this->getQueueConfigDataMethodType()
67 $object = $this->getMockBuilder(\
Magento\Customer\Api\
Data\CustomerInterface::class)
68 ->disableOriginalConstructor()
72 $this->model->validate(
'customer.created', [$object,
'password',
'redirect'],
true);
77 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn(
78 $this->getQueueConfigDataObjectType()
80 $this->model->validate(
'customer.created', [],
true);
89 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn(
90 $this->getQueueConfigDataMethodType()
92 $this->model->validate(
'customer.created', [1, 2, 3],
true);
100 private function getQueueConfigDataObjectType()
103 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
104 CommunicationConfig::TOPIC_REQUEST => \Magento\Customer\Api\Data\CustomerInterface::class
113 private function getQueueConfigDataMethodType()
116 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_METHOD,
117 CommunicationConfig::TOPIC_REQUEST => [
119 'param_name' =>
'customer',
120 'param_position' => 0,
121 'is_required' =>
true,
122 'param_type' => \Magento\Customer\Api\Data\CustomerInterface::class,
125 'param_name' =>
'password',
126 'param_position' => 1,
127 'is_required' =>
false,
128 'param_type' =>
'string',
131 'param_name' =>
'redirectUrl',
132 'param_position' => 2,
133 'is_required' =>
false,
134 'param_type' =>
'string',
145 $this->communicationConfigMock->expects($this->any())->method(
'getTopic')->willReturn($requestType);
146 if ($expectedResult) {
147 $this->expectException(
'InvalidArgumentException');
148 $this->expectExceptionMessage($expectedResult);
150 $this->model->validate(
'topic',
$message);
158 $customerMock = $this->getMockBuilder(\
Magento\Customer\Api\
Data\CustomerInterface::class)
159 ->disableOriginalConstructor()
162 $customerMockTwo = $this->getMockBuilder(\
Magento\Customer\Api\
Data\CustomerInterface::class)
163 ->disableOriginalConstructor()
170 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
171 CommunicationConfig::TOPIC_REQUEST =>
'string' 178 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
179 CommunicationConfig::TOPIC_REQUEST =>
'string' 182 'Data in topic "topic" must be of type "string". "int" given.' 186 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
187 CommunicationConfig::TOPIC_REQUEST =>
'string[]' 189 [
'string1',
'string2'],
194 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
195 CommunicationConfig::TOPIC_REQUEST =>
'string[]' 202 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
203 CommunicationConfig::TOPIC_REQUEST =>
'string[]' 206 'Data in topic "topic" must be of type "string[]". "string" given.' 210 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
211 CommunicationConfig::TOPIC_REQUEST => \Magento\Customer\Api\Data\CustomerInterface::class
218 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
219 CommunicationConfig::TOPIC_REQUEST => \Magento\Customer\Api\Data\CustomerInterface::class
222 'Data in topic "topic" must be of type "Magento\Customer\Api\Data\CustomerInterface". "string" given.' 226 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
227 CommunicationConfig::TOPIC_REQUEST =>
'Magento\Customer\Api\Data\CustomerInterface[]' 229 [$customerMock, $customerMockTwo],
234 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
235 CommunicationConfig::TOPIC_REQUEST =>
'Magento\Customer\Api\Data\CustomerInterface[]' 242 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
243 CommunicationConfig::TOPIC_REQUEST =>
'Magento\Customer\Api\Data\CustomerInterface[]' 246 'Data in topic "topic" must be of type "Magento\Customer\Api\Data\CustomerInterface[]". "string" given.' 250 CommunicationConfig::TOPIC_REQUEST_TYPE => CommunicationConfig::TOPIC_REQUEST_TYPE_CLASS,
251 CommunicationConfig::TOPIC_REQUEST =>
'Magento\Customer\Api\Data\CustomerInterface[]' 254 'Data in topic "topic" must be of type "Magento\Customer\Api\Data\CustomerInterface[]". '
testEncodeValidMessageObjectType()
testValidateValidObjectType()
testInvalidMessageType($requestType, $message, $expectedResult=null)
testValidateValidMethodType()
testValidateInvalidTopic()
testEncodeInvalidMessageMethodType()
getQueueConfigRequestType()