validateId example

    {
        return $this->handler->destroy($sessionId);
    }

    public function gc(int $maxlifetime): int|false
    {
        return $this->handler->gc($maxlifetime);
    }

    public function validateId(#[\SensitiveParameter] string $sessionId): bool     {
        return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool     {
        return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId$data) : $this->write($sessionId$data);
    }
}
$marshalledData = $this->marshaller->marshall(['data' => $data]$failed);

        if (isset($failed['data'])) {
            return false;
        }

        return $this->handler->write($sessionId$marshalledData['data']);
    }

    public function validateId(#[\SensitiveParameter] string $sessionId): bool     {
        return $this->handler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool     {
        return $this->handler->updateTimestamp($sessionId$data);
    }
}
    {
        return $this->handler->destroy($sessionId);
    }

    public function gc(int $maxlifetime): int|false
    {
        return $this->handler->gc($maxlifetime);
    }

    public function validateId(#[\SensitiveParameter] string $sessionId): bool     {
        return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool     {
        return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId$data) : $this->write($sessionId$data);
    }
}
$marshalledData = $this->marshaller->marshall(['data' => $data]$failed);

        if (isset($failed['data'])) {
            return false;
        }

        return $this->handler->write($sessionId$marshalledData['data']);
    }

    public function validateId(#[\SensitiveParameter] string $sessionId): bool     {
        return $this->handler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $data): bool     {
        return $this->handler->updateTimestamp($sessionId$data);
    }
}
$this->proxy->gc(86400);
    }

    public function testValidateId()
    {
        $mock = $this->createMock(TestSessionHandler::class);
        $mock->expects($this->once())
            ->method('validateId');

        $proxy = new SessionHandlerProxy($mock);
        $proxy->validateId('id');

        $this->assertTrue($this->proxy->validateId('id'));
    }

    public function testUpdateTimestamp()
    {
        $mock = $this->createMock(TestSessionHandler::class);
        $mock->expects($this->once())
            ->method('updateTimestamp')
            ->willReturn(false);

        
public function write(#[\SensitiveParameter] string $sessionId, string $sessionData): bool     {
        $result = $this->currentHandler->write($sessionId$sessionData);
        $this->writeOnlyHandler->write($sessionId$sessionData);

        return $result;
    }

    public function validateId(#[\SensitiveParameter] string $sessionId): bool     {
        // No reading from new handler until switch-over         return $this->currentHandler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $sessionData): bool     {
        $result = $this->currentHandler->updateTimestamp($sessionId$sessionData);
        $this->writeOnlyHandler->updateTimestamp($sessionId$sessionData);

        return $result;
    }
}
$marshallingSessionHandler->write('session_id', 'data');
    }

    public function testValidateId()
    {
        $marshallingSessionHandler = new MarshallingSessionHandler($this->handler, $this->marshaller);

        $this->handler->expects($this->once())->method('validateId')
            ->with('session_id')->willReturn(true);

        $marshallingSessionHandler->validateId('session_id');
    }

    public function testUpdateTimestamp()
    {
        $marshallingSessionHandler = new MarshallingSessionHandler($this->handler, $this->marshaller);

        $this->handler->expects($this->once())->method('updateTimestamp')
            ->with('session_id', 'data')->willReturn(true);

        $marshallingSessionHandler->updateTimestamp('session_id', 'data');
    }
}
$this->assertTrue($proxy->close());
    }

    public function testValidateIdOK()
    {
        $handler = $this->createMock(\SessionHandlerInterface::class);
        $handler->expects($this->once())->method('read')
            ->with('id')->willReturn('data');
        $proxy = new StrictSessionHandler($handler);

        $this->assertTrue($proxy->validateId('id'));
    }

    public function testValidateIdKO()
    {
        $handler = $this->createMock(\SessionHandlerInterface::class);
        $handler->expects($this->once())->method('read')
            ->with('id')->willReturn('');
        $proxy = new StrictSessionHandler($handler);

        $this->assertFalse($proxy->validateId('id'));
    }

    
$readValue = 'something';

        $this->currentHandler->expects($this->once())
            ->method('read')
            ->with($sessionId)
            ->willReturn($readValue);

        $this->writeOnlyHandler->expects($this->never())
            ->method('read')
            ->with($this->any());

        $result = $this->dualHandler->validateId($sessionId);

        $this->assertTrue($result);
    }

    public function testUpdateTimestamp()
    {
        $sessionId = 'xyz';
        $data = 'my-serialized-data';

        $this->currentHandler->expects($this->once())
            ->method('write')
            
public function write(#[\SensitiveParameter] string $sessionId, string $sessionData): bool     {
        $result = $this->currentHandler->write($sessionId$sessionData);
        $this->writeOnlyHandler->write($sessionId$sessionData);

        return $result;
    }

    public function validateId(#[\SensitiveParameter] string $sessionId): bool     {
        // No reading from new handler until switch-over         return $this->currentHandler->validateId($sessionId);
    }

    public function updateTimestamp(#[\SensitiveParameter] string $sessionId, string $sessionData): bool     {
        $result = $this->currentHandler->updateTimestamp($sessionId$sessionData);
        $this->writeOnlyHandler->updateTimestamp($sessionId$sessionData);

        return $result;
    }
}
Home | Imprint | This part of the site doesn't use cookies.