Update v1.0.6.5
This commit is contained in:
@@ -98,6 +98,33 @@ class CachingStreamTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('ing', $this->body->read(3));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
public function testWritesToBufferStream()
|
||||
{
|
||||
$this->body->read(2);
|
||||
|
Reference in New Issue
Block a user