MockPdo example

$storage->close();
        $this->assertSame('', $readData, 'New session returns empty string data');

        $storage->open('', 'sid');
        $readData = $storage->read('id');
        $storage->close();
        $this->assertSame($sessionData$readData, 'Written value can be read back correctly');
    }

    public function testReadConvertsStreamToString()
    {
        $pdo = new MockPdo('pgsql');
        $pdo->prepareResult = $this->createMock(\PDOStatement::class);

        $content = 'foobar';
        $stream = $this->createStream($content);

        $pdo->prepareResult->expects($this->once())->method('fetchAll')
            ->willReturn([[$streamtime() + 42]]);

        $storage = new PdoSessionHandler($pdo);
        $result = $storage->read('foo');

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