public function testReadWriteThreeTimesAndGc() { $config = $this->_saveHandlerTableConfig; unset($config[Zend_Session_SaveHandler_DbTable::PRIMARY_ASSIGNMENT]); $config['primary'] = array($config['primary'][0]); $config['lifetime'] = 1; $this->_setupDb($config['primary']); $this->_usedSaveHandlers[] = $saveHandler = new Zend_Session_SaveHandler_DbTable($config); $id = 242; $this->assertTrue($saveHandler->write($id, serialize($config))); $this->assertSame($config, unserialize($saveHandler->read($id))); $id++; $this->assertTrue($saveHandler->write($id, serialize($config))); $this->assertSame($config, unserialize($saveHandler->read($id))); $id++; $this->assertTrue($saveHandler->write($id, serialize($config))); $this->assertSame($config, unserialize($saveHandler->read($id))); foreach ($this->_db->query('SELECT * FROM Sessions')->fetchAll() as $row) { $this->assertSame($config, unserialize($row['data'])); } sleep(2); $saveHandler->gc(false); foreach ($this->_db->query('SELECT * FROM Sessions')->fetchAll() as $row) { //should be empty! $this->fail(); } }
/** * Write session data * * @param string $id * @param string $data * @return boolean */ public function write($id, $data) { parent::write($id, $data); // Discard parent's return value and return true (PHP 7 actually cares about this) return true; }