8 use Composer\Autoload\ClassLoader;
17 use PHPUnit\Framework\MockObject_MockObject as MockObject;
27 private $communicationConfig;
37 private $objectManager;
46 $this->communicationConfig = $this->getMockBuilder(CommunicationConfigInterface::class)
47 ->disableOriginalConstructor()
52 'Magento\\Framework\\MessageQueue\\Code\\Generator\\',
70 $this->createGenerator($sourceClassName, $resultClassName);
72 $this->communicationConfig->method(
'getTopic')
75 [$topicName .
'.save', [CommunicationConfigInterface::TOPIC_IS_SYNCHRONOUS =>
true]],
76 [$topicName .
'.get', [CommunicationConfigInterface::TOPIC_IS_SYNCHRONOUS =>
true]],
77 [$topicName .
'.getById', [CommunicationConfigInterface::TOPIC_IS_SYNCHRONOUS =>
true]],
78 [$topicName .
'.getList', [CommunicationConfigInterface::TOPIC_IS_SYNCHRONOUS =>
true]],
79 [$topicName .
'.delete', [CommunicationConfigInterface::TOPIC_IS_SYNCHRONOUS =>
true]],
80 [$topicName .
'.deleteById', [CommunicationConfigInterface::TOPIC_IS_SYNCHRONOUS =>
true]],
84 $this->validateGeneratedCode($expectedResult);
96 '\\' . \Magento\Customer\Api\CustomerRepositoryInterface::class,
97 '\\' . \Magento\Customer\Api\CustomerRepositoryInterfaceRemote::class,
98 'magento.customer.api.customerRepositoryInterface',
102 '\\' . \Magento\Framework\MessageQueue\Code\Generator\TRepositoryInterface::class,
103 '\\' . \Magento\Framework\MessageQueue\Code\Generator\TRepositoryInterfaceRemote::class,
104 'magento.framework.messageQueue.code.generator.tRepositoryInterface',
116 private function validateGeneratedCode($expectedResult)
118 $reflectionObject = new \ReflectionObject($this->generator);
119 $reflectionMethod = $reflectionObject->getMethod(
'_generateCode');
120 $reflectionMethod->setAccessible(
true);
131 private function createGenerator($sourceClassName, $resultClassName)
133 $methodMap = $this->createMethodMap();
134 $this->generator = $this->objectManager->getObject(
135 RemoteServiceGenerator::class,
137 'communicationConfig' => $this->communicationConfig,
138 'serviceMethodsMap' => $methodMap,
139 'sourceClassName' => $sourceClassName,
140 'resultClassName' => $resultClassName,
141 'classGenerator' =>
null 145 $reflectionGenerator = $this->objectManager->getObject(ReflectionGenerator::class);
146 $this->objectManager->setBackwardCompatibleProperty(
148 'reflectionGenerator',
158 private function createMethodMap()
160 $cache = $this->getMockBuilder(FrontendInterface::class)
161 ->disableOriginalConstructor()
166 $serializer = $this->getMockBuilder(SerializerInterface::class)
167 ->disableOriginalConstructor()
169 $typeProcessor = $this->objectManager->getObject(TypeProcessor::class);
172 $serviceMethodMap = $this->objectManager->getObject(MethodsMap::class, [
174 'typeProcessor' => $typeProcessor
176 $this->objectManager->setBackwardCompatibleProperty(
182 return $serviceMethodMap;
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testGenerate($sourceClassName, $resultClassName, $topicName, $fileName)