public function testSessionDestroy() { $storage = new PdoSessionHandler($this->pdo, array('db_table' => 'sessions'), array()); $storage->write('foo', 'bar'); $this->assertEquals(1, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); $storage->destroy('foo'); $this->assertEquals(0, count($this->pdo->query('SELECT * FROM sessions')->fetchAll())); }
private function testOperations(PDO $connection, array $parameters) { $options = array('db_table' => $parameters['session_db_table'], 'db_id_col' => $parameters['session_db_id_col'], 'db_data_col' => $parameters['session_db_data_col'], 'db_time_col' => $parameters['session_db_time_col']); $errors = array(); $handler = new PdoSessionHandler($connection, $options); $connection->beginTransaction(); try { $handler->write('session_1', 'session 1 data...'); $handler->write('session_2', 'session 2 data...'); $handler->read('session_1'); $handler->read('session_2'); $handler->destroy('session 1'); $handler->gc(1); } catch (\Exception $ex) { $errors[] = 'session_db_cannot_perform_operations'; } $connection->rollBack(); return $errors; }
public function testSessionDestroy() { $pdo = $this->getMemorySqlitePdo(); $storage = new PdoSessionHandler($pdo); $storage->open('', 'sid'); $storage->read('id'); $storage->write('id', 'data'); $storage->close(); $this->assertEquals(1, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); $storage->open('', 'sid'); $storage->read('id'); $storage->destroy('id'); $storage->close(); $this->assertEquals(0, $pdo->query('SELECT COUNT(*) FROM sessions')->fetchColumn()); $storage->open('', 'sid'); $data = $storage->read('id'); $storage->close(); $this->assertSame('', $data, 'Destroyed session returns empty string'); }