get('Magento\Customer\Model\Session'); $session->loginById($customerId); } /** * @magentoDataFixture Magento/Customer/_files/customer.php */ public function testLogoutAction() { $this->login(1); $this->dispatch('customer/ajax/logout'); $body = $this->getResponse()->getBody(); $logoutMessage = Bootstrap::getObjectManager()->get('Magento\Framework\Json\Helper\Data')->jsonDecode($body); $this->assertContains('Logout Successful', $logoutMessage['message']); } }