objectManager = Bootstrap::getObjectManager(); $this->customerSession = $this->objectManager->get(CustomerSession::class); $this->sessionFactory = $this->objectManager->get(SessionFactory::class); } /** * @magentoConfigFixture current_store persistent/options/enabled 1 * @magentoConfigFixture current_store persistent/options/logout_clear 1 * * @return void */ public function testSynchronizePersistentOnLogout(): void { $this->customerSession->loginById(1); $sessionModel = $this->sessionFactory->create(); $sessionModel->loadByCookieKey(); $this->assertEquals(1, $sessionModel->getCustomerId()); $this->customerSession->logout(); $sessionModel = $this->sessionFactory->create(); $sessionModel->loadByCookieKey(); $this->assertNull($sessionModel->getCustomerId()); } /** * @magentoConfigFixture current_store persistent/options/enabled 1 * @magentoConfigFixture current_store persistent/options/logout_clear 0 * * @return void */ public function testSynchronizePersistentOnLogoutDisabled(): void { $this->customerSession->loginById(1); $this->customerSession->logout(); $sessionModel = $this->sessionFactory->create(); $sessionModel->loadByCookieKey(); $this->assertEquals(1, $sessionModel->getCustomerId()); } }