Exemplo n.º 1
0
 /**
  * @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->executeInternal();
 }