Esempio n. 1
0
 public function testNewsletterAction()
 {
     $subscriberMock = $this->getMock('\\Magento\\Newsletter\\Model\\Subscriber', array(), array(), '', false);
     $subscriberMock->expects($this->once())->method('loadByCustomerId');
     $this->_objectManager->expects($this->at(1))->method('create')->with('Magento\\Newsletter\\Model\\Subscriber')->will($this->returnValue($subscriberMock));
     $this->_testedObject->execute();
 }
Esempio n. 2
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->at(1))->method('create')->with('Magento\\Newsletter\\Model\\Subscriber')->will($this->returnValue($subscriberMock));
     $this->assertInstanceOf('Magento\\Framework\\View\\Result\\Layout', $this->_testedObject->execute());
 }
Esempio n. 3
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('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->execute());
 }
Esempio n. 4
0
 public function testResetPasswordActionSendEmail()
 {
     $customerId = 1;
     $email = "*****@*****.**";
     $websiteId = 1;
     $redirectLink = 'http://example.com';
     $this->_request->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'), $this->equalTo(0))->will($this->returnValue($customerId));
     $customerBuilder = $this->getMock('\\Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder', [], [], '', false);
     $data = ['id' => $customerId, 'email' => $email, 'website_id' => $websiteId];
     $customerBuilder->expects($this->once())->method('getData')->will($this->returnValue($data));
     $customer = new \Magento\Customer\Service\V1\Data\Customer($customerBuilder);
     $this->_acctServiceMock->expects($this->once())->method('getCustomer')->with($customerId)->will($this->returnValue($customer));
     // verify initiatePasswordReset() is called
     $this->_acctServiceMock->expects($this->once())->method('initiatePasswordReset')->with($email, CustomerAccountServiceInterface::EMAIL_REMINDER, $websiteId);
     // verify success message
     $this->messageManager->expects($this->once())->method('addSuccess')->with($this->equalTo('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(array('id' => $customerId, '_current' => true)))->will($this->returnValue($redirectLink));
     $this->_response->expects($this->once())->method('setRedirect')->with($this->equalTo($redirectLink));
     $this->_testedObject->execute();
 }