コード例 #1
0
ファイル: ValidateTest.php プロジェクト: nblair/magescotch
 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->executeInternal());
 }