public function testAroundDeleteById()
 {
     $customerId = 1;
     $deleteCustomerById = function () {
         return true;
     };
     $subject = $this->getMock('\\Magento\\Customer\\Api\\CustomerRepositoryInterface');
     $customer = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface');
     $subject->expects($this->once())->method('getById')->willReturn($customer);
     $customer->expects($this->once())->method('getEmail')->willReturn('*****@*****.**');
     $this->subscriber->expects($this->once())->method('loadByEmail')->with('*****@*****.**')->willReturnSelf();
     $this->subscriber->expects($this->once())->method('getId')->willReturn(1);
     $this->subscriber->expects($this->once())->method('delete')->willReturnSelf();
     $this->assertEquals(true, $this->plugin->aroundDeleteById($subject, $deleteCustomerById, $customerId));
 }
예제 #2
0
 public function testExecute()
 {
     $customersIds = [10, 11, 12];
     $this->customerCollectionMock->expects($this->any())->method('getAllIds')->willReturn($customersIds);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->willReturnMap([[10, true], [11, true], [12, true]]);
     $this->subscriberMock->expects($this->any())->method('unsubscribeCustomerById')->willReturnMap([[10, true], [11, true], [12, true]]);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('A total of %1 record(s) were updated.', count($customersIds)));
     $this->resultRedirectMock->expects($this->any())->method('setPath')->with('customer/*/index')->willReturnSelf();
     $this->massAction->execute();
 }
 /**
  * @param $customerId
  * @param $password
  * @param $confirmationStatus
  * @param $successUrl
  * @param $isSetFlag
  * @param $successMessage
  *
  * @dataProvider getSuccessRedirectDataProvider
  */
 public function testSuccessRedirect($customerId, $password, $confirmationStatus, $successUrl, $isSetFlag, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registration->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->once())->method('regenerateId');
     $this->customerMock->expects($this->any())->method('getId')->will($this->returnValue($customerId));
     $this->customerExtractorMock->expects($this->any())->method('extract')->with($this->equalTo('customer_account_create'), $this->equalTo($this->requestMock))->will($this->returnValue($this->customerMock));
     $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['password', null, $password], ['password_confirmation', null, $password], ['is_subscribed', false, true]]);
     $this->customerMock->expects($this->once())->method('setAddresses')->with($this->equalTo([]))->will($this->returnSelf());
     $this->accountManagement->expects($this->once())->method('createAccount')->with($this->equalTo($this->customerDetailsMock), $this->equalTo($password), '')->will($this->returnValue($this->customerMock));
     $this->accountManagement->expects($this->once())->method('getConfirmationStatus')->with($this->equalTo($customerId))->will($this->returnValue($confirmationStatus));
     $this->subscriberMock->expects($this->once())->method('subscribeCustomerById')->with($this->equalTo($customerId));
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->will($this->returnSelf());
     $this->urlMock->expects($this->any())->method('getUrl')->willReturnMap([['*/*/index', ['_secure' => true], $successUrl], ['*/*/create', ['_secure' => true], $successUrl]]);
     $this->redirectMock->expects($this->once())->method('success')->with($this->equalTo($successUrl))->will($this->returnValue($successUrl));
     $this->scopeConfigMock->expects($this->once())->method('isSetFlag')->with($this->equalTo(Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD), $this->equalTo(ScopeInterface::SCOPE_STORE))->will($this->returnValue($isSetFlag));
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->model->execute();
 }