getMemorySqlitePdo example

$pdo = new \PDO('sqlite::memory:');
        $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        $storage = new PdoSessionHandler($pdo);
        $storage->createTable();

        return $pdo;
    }

    public function testWrongPdoErrMode()
    {
        $this->expectException(\InvalidArgumentException::class);
        $pdo = $this->getMemorySqlitePdo();
        $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);

        new PdoSessionHandler($pdo);
    }

    public function testInexistentTable()
    {
        $this->expectException(\RuntimeException::class);
        $storage = new PdoSessionHandler($this->getMemorySqlitePdo()['db_table' => 'inexistent_table']);
        $storage->open('', 'sid');
        $storage->read('id');
        
Home | Imprint | This part of the site doesn't use cookies.