Esempio n. 1
0
 /**
  * @param int $counter
  * @param string $message
  * @param string $exception
  *
  * @dataProvider exceptionDataProvider
  */
 public function testGeneralException($counter, $message, $exception)
 {
     $customerId = 1;
     $address = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\AddressInterface')->getMockForAbstractClass();
     $currentCustomerMock = $this->getCurrentCustomerMock($address);
     $newCustomerMock = $this->getNewCustomerMock($customerId, $address);
     $exception = new $exception(__($message));
     $this->validator->expects($this->once())->method('validate')->with($this->request)->willReturn(true);
     $this->request->expects($this->once())->method('isPost')->willReturn(true);
     $this->request->expects($this->once())->method('getParam')->with('change_password')->willReturn(false);
     $this->request->expects($this->any())->method('getPostValue')->willReturn(true);
     $this->session->expects($this->once())->method('getCustomerId')->willReturn($customerId);
     $this->session->expects($this->once())->method('setCustomerFormData')->with(true)->willReturnSelf();
     $this->customerRepository->expects($this->once())->method('getById')->with($customerId)->willReturn($currentCustomerMock);
     $this->customerRepository->expects($this->once())->method('save')->with($newCustomerMock)->willThrowException($exception);
     $this->customerExtractor->expects($this->once())->method('extract')->with('customer_account_edit', $this->request)->willReturn($newCustomerMock);
     $this->messageManager->expects($this->once())->method('getMessages')->willReturn($this->messageCollection);
     $this->messageCollection->expects($this->once())->method('getCount')->willReturn($counter);
     $this->resultRedirect->expects($this->once())->method('setPath')->with('*/*/edit')->willReturnSelf();
     $this->assertSame($this->resultRedirect, $this->model->executeInternal());
 }