public function testExecuteWhenSessionNotPersist() { $this->helperMock->expects($this->once())->method('canProcess')->with($this->observerMock)->will($this->returnValue(true)); $this->helperMock->expects($this->once())->method('isShoppingCartPersist')->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(true)); $this->customerRepositoryMock->expects($this->never())->method('get'); $this->model->execute($this->observerMock); }
/** * @magentoAppArea frontend * @magentoConfigFixture current_store persistent/options/shopping_cart 1 * @magentoConfigFixture current_store persistent/options/logout_clear 0 * @magentoConfigFixture current_store persistent/options/enabled 1 */ public function testEmulateCustomer() { $observer = new \Magento\Framework\Event\Observer(); $this->_customerSession->loginById(1); $this->_customerSession->logout(); $this->assertNull($this->_customerSession->getCustomerId()); $this->assertEquals(\Magento\Customer\Service\V1\CustomerGroupServiceInterface::NOT_LOGGED_IN_ID, $this->_customerSession->getCustomerGroupId()); $this->_observer->execute($observer); $customer = $this->_customerAccountService->getCustomer($this->_persistentSessionHelper->getSession()->getCustomerId()); $this->assertEquals($customer->getId(), $this->_customerSession->getCustomerId()); $this->assertEquals($customer->getGroupId(), $this->_customerSession->getCustomerGroupId()); }
/** * @magentoAppArea frontend * @magentoConfigFixture current_store persistent/options/shopping_cart 1 * @magentoConfigFixture current_store persistent/options/logout_clear 0 * @magentoConfigFixture current_store persistent/options/enabled 1 */ public function testEmulateCustomer() { $observer = new \Magento\Framework\Event\Observer(); $this->_customerSession->loginById(1); $this->_customerSession->logout(); $this->assertNull($this->_customerSession->getCustomerId()); $this->assertEquals(\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID, $this->_customerSession->getCustomerGroupId()); $this->_observer->execute($observer); $customer = $this->customerRepository->getById($this->_persistentSessionHelper->getSession()->getCustomerId()); $this->assertEquals($customer->getId(), $this->_customerSession->getCustomerId()); $this->assertEquals($customer->getGroupId(), $this->_customerSession->getCustomerGroupId()); }