NullSessionHandler example


        session_id('nullsessionstorage');
        $storage = $this->getStorage();
        $session = new Session($storage);
        $session->start();
        $this->assertEquals('nullsessionstorage', $session->getId());
        $this->assertNull($session->get('something'));
    }

    public function getStorage()
    {
        return new NativeSessionStorage([]new NullSessionHandler());
    }
}
public function testSetSaveHandler()
    {
        $this->iniSet('session.save_handler', 'files');
        $storage = $this->getStorage();
        $storage->setSaveHandler(null);
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new SessionHandlerProxy(new NativeFileSessionHandler()));
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new NativeFileSessionHandler());
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new SessionHandlerProxy(new NullSessionHandler()));
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
        $storage->setSaveHandler(new NullSessionHandler());
        $this->assertInstanceOf(SessionHandlerProxy::class$storage->getSaveHandler());
    }

    public function testStarted()
    {
        $this->expectException(\RuntimeException::class);
        $storage = $this->getStorage();

        $this->assertFalse($storage->getSaveHandler()->isActive());
        
Home | Imprint | This part of the site doesn't use cookies.