public function testIsValidForHost() { $_SERVER['HTTP_HOST'] = 'localhost'; $this->_model->start('test'); $reflection = new \ReflectionMethod($this->_model, '_addHost'); $reflection->setAccessible(true); $reflection->invoke($this->_model); $this->assertFalse($this->_model->isValidForHost('test.com')); $this->assertTrue($this->_model->isValidForHost('localhost')); $this->_model->destroy(); }
/** * @expectedException \Magento\Framework\Exception\SessionException * @expectedExceptionMessage Area code not set: Area code must be set before starting a session. */ public function testStartAreaNotSet() { $scope = $this->objectManager->get('Magento\\Framework\\Config\\ScopeInterface'); $appState = new \Magento\Framework\App\State($scope); /** * Must be created by "new" in order to get a real Magento\Framework\App\State object that * is not overridden in the TestFramework * * @var \Magento\Framework\Session\SessionManager _model */ $this->_model = new \Magento\Framework\Session\SessionManager($this->objectManager->get('Magento\\Framework\\App\\Request\\Http'), $this->_sidResolver, $this->objectManager->get('Magento\\Framework\\Session\\Config\\ConfigInterface'), $this->objectManager->get('Magento\\Framework\\Session\\SaveHandlerInterface'), $this->objectManager->get('Magento\\Framework\\Session\\ValidatorInterface'), $this->objectManager->get('Magento\\Framework\\Session\\StorageInterface'), $this->objectManager->get('Magento\\Framework\\Stdlib\\CookieManagerInterface'), $this->objectManager->get('Magento\\Framework\\Stdlib\\Cookie\\CookieMetadataFactory'), $appState); global $mockPHPFunctions; $mockPHPFunctions = true; $this->_model->start(); }
/** * Retrieve store session object * * @return \Magento\Framework\Session\SessionManagerInterface */ protected function _getSession() { if (!$this->_session->isSessionExists()) { $this->_session->setName('store_' . $this->getCode()); $this->_session->start(); } return $this->_session; }