/**
  * @magentoConfigFixture current_store persistent/options/enabled 1
  * @magentoConfigFixture current_store persistent/options/remember_enabled 1
  * @magentoConfigFixture current_store persistent/options/remember_default 1
  * @magentoAppArea frontend
  * @magentoConfigFixture current_store persistent/options/shopping_cart 1
  * @magentoConfigFixture current_store persistent/options/logout_clear 0
  */
 public function testEmulateQuote()
 {
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->setMethods([])->getMock();
     $requestMock->expects($this->once())->method('getFullActionName')->will($this->returnValue('valid_action'));
     $event = new \Magento\Framework\Event(['request' => $requestMock]);
     $observer = new \Magento\Framework\Event\Observer();
     $observer->setEvent($event);
     $this->_customerSession->loginById(1);
     $customer = $this->customerRepository->getById($this->_persistentSessionHelper->getSession()->getCustomerId());
     $this->_checkoutSession->expects($this->once())->method('setCustomerData')->with($customer);
     $this->_customerSession->logout();
     $this->_observer->execute($observer);
 }
 public function testExecuteWhenShoppingCartIsPersistentAndQuoteExist()
 {
     $customerId = 1;
     $this->helperMock->expects($this->once())->method('canProcess')->with($this->observerMock)->will($this->returnValue(true));
     $this->sessionHelperMock->expects($this->once())->method('isPersistent')->will($this->returnValue(true));
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->observerMock->expects($this->once())->method('getEvent')->will($this->returnValue($this->eventMock));
     $this->eventMock->expects($this->once())->method('getRequest')->will($this->returnValue($this->requestMock));
     $this->requestMock->expects($this->once())->method('getFullActionName')->will($this->returnValue('method_name'));
     $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->will($this->returnValue(true));
     $this->sessionHelperMock->expects($this->once())->method('getSession')->will($this->returnValue($this->sessionMock));
     $this->sessionMock->expects($this->once())->method('getCustomerId')->will($this->returnValue($customerId));
     $this->customerRepository->expects($this->once())->method('getById')->with($customerId)->will($this->returnValue($this->customerMock));
     $this->checkoutSessionMock->expects($this->once())->method('hasQuote')->will($this->returnValue(true));
     $this->checkoutSessionMock->expects($this->once())->method('setCustomerData')->with($this->customerMock);
     $this->model->execute($this->observerMock);
 }