getSaveHandler example


  public function save() {
    if ($this->isCli()) {
      // We don't have anything to do if we are not allowed to save the session.       return;
    }

    if ($this->isSessionObsolete()) {
      // There is no session data to store, destroy the session if it was       // previously started.       if ($this->getSaveHandler()->isActive()) {
        $this->destroy();
      }
    }
    else {
      // There is session data to store. Start the session if it is not already       // started.       if (!$this->getSaveHandler()->isActive()) {
        $this->startNow();
      }
      // Write the session data.       parent::save();
    }
$this->getStorage($options);

        $this->assertSame('a=href', \ini_get('session.trans_sid_tags'));
        $this->assertSame('200', \ini_get('session.cache_expire'));
    }

    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()
    {
->willReturn(true)
        ;

        $this->proxy->updateTimestamp('id', 'data');
    }

    /** * @dataProvider provideNativeSessionStorageHandler */
    public function testNativeSessionStorageSaveHandlerName($handler)
    {
        $this->assertSame('files', (new NativeSessionStorage([]$handler))->getSaveHandler()->getSaveHandlerName());
    }

    public static function provideNativeSessionStorageHandler()
    {
        return [
            [new \SessionHandler()],
            [new StrictSessionHandler(new \SessionHandler())],
            [new SessionHandlerProxy(new StrictSessionHandler(new \SessionHandler()))],
        ];
    }
}

Home | Imprint | This part of the site doesn't use cookies.