public function testStrategy() { $strategy = new DefaultStrategy(); $this->assertTrue($strategy instanceof StrategyInterface); SessionHandler::disable(); $uri = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI']; $query = empty($_SERVER['QUERY_STRING']) ? '' : $_SERVER['QUERY_STRING']; $md5 = md5($uri . $_SERVER['SCRIPT_NAME'] . $query); $this->assertEquals($md5, $strategy->strategy()); SessionHandler::enable(); $this->assertNotEmpty($strategy->strategy()); }
/** * @depends testEnableDisableStatus * @depends testExcludeKeys */ public function testProcess() { $_SESSION['testing'] = 'somevar'; SessionHandler::setStatus(false); $this->assertNull(SessionHandler::process()); SessionHandler::enable(); $this->assertContains('somevar', SessionHandler::process()); $this->assertEquals(serialize($_SESSION), SessionHandler::process()); $_SESSION['process'] = 'ignorethis'; $this->assertEquals(serialize($_SESSION), SessionHandler::process()); SessionHandler::excludeKeys(array('NonExistingSessionVariable')); SessionHandler::excludeKeys(array('process')); $process = SessionHandler::process(); $this->assertEquals(array('testing' => 'somevar'), unserialize($process)); }
/** * Use sessions when caching page. * For the same URL session enabled page might be displayed differently, when for example user has logged in. */ public function enableSession() { SessionHandler::enable(); }