public function testExecute() { $country = 'US'; $vat = '123456789'; $isValid = true; $requestMessage = 'test'; $json = '{"valid":' . (int) $isValid . ',"message":"' . $requestMessage . '"}'; $gatewayResponse = new \Magento\Framework\DataObject(['is_valid' => $isValid, 'request_message' => $requestMessage]); $this->request->expects($this->any())->method('getParam')->willReturnMap([['country', null, $country], ['vat', null, $vat]]); $vatMock = $this->getMockBuilder('Magento\\Customer\\Model\\Vat')->disableOriginalConstructor()->getMock(); $vatMock->expects($this->once())->method('checkVatNumber')->with($country, $vat)->willReturn($gatewayResponse); $this->objectManager->expects($this->once())->method('get')->with('Magento\\Customer\\Model\\Vat')->willReturn($vatMock); $this->resultJson->expects($this->once())->method('setData')->with(['valid' => $gatewayResponse->getIsValid(), 'message' => $gatewayResponse->getRequestMessage()])->willReturn($json); $this->assertEquals($json, $this->controller->execute()); }
/** * {@inheritdoc} */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch'); if (!$pluginInfo) { return parent::dispatch($request); } else { return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo); } }