Esempio n. 1
0
 /**
  * Check if validation throws a localized catched exception in case of incorrect id
  */
 public function testExecuteException()
 {
     $taxRateId = 999;
     $exceptionMessage = __('An error occurred while loading this tax rate.');
     $noSuchEntityEx = new \Exception();
     $objectManager = new ObjectManager($this);
     $this->request->expects($this->any())->method('getParam')->will($this->returnValue($taxRateId));
     $this->taxRateRepository->expects($this->any())->method('get')->with($taxRateId)->willThrowException($noSuchEntityEx);
     $jsonObject = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->setMethods(['setData'])->getMock();
     $jsonObject->expects($this->once())->method('setData')->with(['success' => false, 'error_message' => $exceptionMessage]);
     $this->resultFactory->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_JSON)->willReturn($jsonObject);
     $notification = $objectManager->getObject('Magento\\Tax\\Controller\\Adminhtml\\Rate\\AjaxLoad', ['taxRateRepository' => $this->taxRateRepository, 'request' => $this->request, 'resultFactory' => $this->resultFactory]);
     //exception thrown with catch
     $this->assertSame($jsonObject, $notification->execute());
 }