Пример #1
0
 public function testNewsletterAction()
 {
     $subscriberMock = $this->getMock('\\Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $this->resultLayoutFactoryMock->expects($this->once())->method('create')->willReturn($this->resultLayoutMock);
     $subscriberMock->expects($this->once())->method('loadByCustomerId');
     $this->_objectManager->expects($this->any())->method('create')->with('Magento\\Newsletter\\Model\\Subscriber')->willReturn($subscriberMock);
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Layout', $this->_testedObject->executeInternal());
 }
Пример #2
0
 public function testResetPasswordActionSendEmail()
 {
     $customerId = 1;
     $email = '*****@*****.**';
     $websiteId = 1;
     $redirectLink = 'customer/*/edit';
     $this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
     $customer = $this->getMockForAbstractClass('\\Magento\\Customer\\Api\\Data\\CustomerInterface', ['getId', 'getEmail', 'getWebsiteId']);
     $customer->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $customer->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $this->_customerRepositoryMock->expects($this->once())->method('getById')->with($customerId)->will($this->returnValue($customer));
     // verify initiatePasswordReset() is called
     $this->_customerAccountManagementMock->expects($this->once())->method('initiatePasswordReset')->with($email, AccountManagement::EMAIL_REMINDER, $websiteId);
     // verify success message
     $this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('The customer will receive an email with a link to reset password.'));
     // verify redirect
     $this->_helper->expects($this->any())->method('getUrl')->with($this->equalTo('customer/*/edit'), $this->equalTo(['id' => $customerId, '_current' => true]))->will($this->returnValue($redirectLink));
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with($redirectLink, ['id' => $customerId, '_current' => true]);
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->_testedObject->executeInternal());
 }