public function testGc() { $this->_model->write('test', 'test'); $this->assertEquals('test', $this->_model->read('test')); $this->_model->gc(-1); $this->assertEmpty($this->_model->read('test')); }
public function testWriteReadDestroy() { $sessionId = 'my_test_id'; $data = serialize(array('test key' => 'test value')); $this->_model->write($sessionId, $data); $this->assertEquals($data, $this->_model->read($sessionId)); $data = serialize(array('new key' => 'new value')); $this->_model->write($sessionId, $data); $this->assertEquals($data, $this->_model->read($sessionId)); $this->_model->destroy($sessionId); $this->assertEmpty($this->_model->read($sessionId)); }
/** * Assert that session data writes to DB in base64 encoding */ public function testWriteEncoded() { $data = serialize($this->_sessionData[self::SESSION_NEW]); $this->_model->write(self::SESSION_ID, $data); $select = $this->_connection->select()->from($this->_sessionTable)->where(self::COLUMN_SESSION_ID . ' = :' . self::COLUMN_SESSION_ID); $bind = array(self::COLUMN_SESSION_ID => self::SESSION_ID); $session = $this->_connection->fetchRow($select, $bind); $this->assertEquals(self::SESSION_ID, $session[self::COLUMN_SESSION_ID]); $this->assertTrue(ctype_digit((string) $session[self::COLUMN_SESSION_EXPIRES]), 'Value of session expire field must have integer type'); $this->assertEquals($data, base64_decode($session[self::COLUMN_SESSION_DATA])); }
/** * @param bool $sessionExists * * @dataProvider writeDataProvider */ public function testWrite($sessionExists) { $this->_prepareMockForWrite($sessionExists); $this->assertTrue($this->_model->write(self::SESSION_ID, self::SESSION_DATA)); }