/** * @runInSeparateProcess */ public function testExpiredSession() { $MysqlAdapter = new MysqlPDOAdapter($GLOBALS['db_type'] . ':host=' . $GLOBALS['db_host'] . ';dbname=' . $GLOBALS['db_name'] . ';charset=utf8mb4', $GLOBALS['db_username'], $GLOBALS['db_password'], array(\PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_OBJ, \PDO::ATTR_ERRMODE => \PDO::ERRMODE_WARNING)); $dbase = new Database($MysqlAdapter); $sessionHandler = new DatabaseSessionHandler($dbase); $session = new Session(['expire' => 8]); $session->setSessionHandler($sessionHandler); $session->start(); $session_id = $session->id; $session->time = $session->time - 1800; $session->commit(); $session->setSessionHandler($sessionHandler); $session->start(); $session_id2 = $session->id; $test = $session_id === $session_id2 ? 1 : 0; $this->assertEquals(0, $test); $session->destroy(); }
/** * @runInSeparateProcess */ public function testExpiredSession() { if (!class_exists('Memcached')) { $this->markTestSkipped('Memcached module not installed'); } //create memcached instance $memcached = new Memcached(); //connect to memcached server $memcached->addServer($GLOBALS['mem_host'], $GLOBALS['mem_port']); $sessionHandler = new MemcachedSessionHandler($memcached, 8); $session = new Session(['expire' => 8]); $session->setSessionHandler($sessionHandler); $session->start(); $session_id = $session->id; $session->time = $session->time - 1800; $session->commit(); $session->setSessionHandler($sessionHandler); $session->start(); $session_id2 = $session->id; $test = $session_id === $session_id2 ? 1 : 0; $this->assertEquals(0, $test); $session->destroy(); }