Пример #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();
 }
Пример #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());
 }
Пример #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());
 }
Пример #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();
 }
Пример #5
0
 /**
  * @param \Magento\Backend\App\Action\Context $context
  * @param \Magento\Framework\Registry $coreRegistry
  * @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
  * @param \Magento\Customer\Model\CustomerFactory $customerFactory
  * @param \Magento\Customer\Model\AddressFactory $addressFactory
  * @param \Magento\Customer\Model\Metadata\FormFactory $formFactory
  * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory
  * @param \Magento\Customer\Helper\View $viewHelper
  * @param \Magento\Framework\Math\Random $random
  * @param CustomerRepositoryInterface $customerRepository
  * @param \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter
  * @param Mapper $addressMapper
  * @param AccountManagementInterface $customerAccountManagement
  * @param AddressRepositoryInterface $addressRepository
  * @param CustomerInterfaceFactory $customerDataFactory
  * @param AddressInterfaceFactory $addressDataFactory
  * @param \Magento\Customer\Model\Customer\Mapper $customerMapper
  * @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor
  * @param DataObjectHelper $dataObjectHelper
  * @param DataObjectFactory $objectFactory
  * @param \Magento\Framework\View\LayoutFactory $layoutFactory
  * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
  * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
  * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
  * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
  * @param CustomerTokenServiceInterface $tokenService
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\App\Response\Http\FileFactory $fileFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Customer\Model\AddressFactory $addressFactory, \Magento\Customer\Model\Metadata\FormFactory $formFactory, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, \Magento\Customer\Helper\View $viewHelper, \Magento\Framework\Math\Random $random, CustomerRepositoryInterface $customerRepository, \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter, Mapper $addressMapper, AccountManagementInterface $customerAccountManagement, AddressRepositoryInterface $addressRepository, CustomerInterfaceFactory $customerDataFactory, AddressInterfaceFactory $addressDataFactory, \Magento\Customer\Model\Customer\Mapper $customerMapper, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, DataObjectHelper $dataObjectHelper, DataObjectFactory $objectFactory, \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory, \Magento\Framework\View\Result\PageFactory $resultPageFactory, \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, CustomerTokenServiceInterface $tokenService)
 {
     $this->tokenService = $tokenService;
     parent::__construct($context, $coreRegistry, $fileFactory, $customerFactory, $addressFactory, $formFactory, $subscriberFactory, $viewHelper, $random, $customerRepository, $extensibleDataObjectConverter, $addressMapper, $customerAccountManagement, $addressRepository, $customerDataFactory, $addressDataFactory, $customerMapper, $dataObjectProcessor, $dataObjectHelper, $objectFactory, $layoutFactory, $resultLayoutFactory, $resultPageFactory, $resultForwardFactory, $resultJsonFactory);
 }