public function testCanSeekToReadBytesWithPartialBodyReturned() { $stream = fopen('php://temp', 'r+'); fwrite($stream, 'testing'); fseek($stream, 0); $this->decorated = $this->getMockBuilder('\\GuzzleHttp\\Psr7\\Stream')->setConstructorArgs([$stream])->setMethods(['read'])->getMock(); $this->decorated->expects($this->exactly(2))->method('read')->willReturnCallback(function ($length) use($stream) { return fread($stream, 2); }); $this->body = new CachingStream($this->decorated); $this->assertEquals(0, $this->body->tell()); $this->body->seek(4, SEEK_SET); $this->assertEquals(4, $this->body->tell()); $this->body->seek(0); $this->assertEquals('test', $this->body->read(4)); }