You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
1 year ago
|
<?php
|
||
|
namespace GuzzleHttp\Tests\Psr7;
|
||
|
|
||
|
use GuzzleHttp\Psr7;
|
||
|
use GuzzleHttp\Psr7\NoSeekStream;
|
||
|
|
||
|
/**
|
||
|
* @covers GuzzleHttp\Psr7\NoSeekStream
|
||
|
* @covers GuzzleHttp\Psr7\StreamDecoratorTrait
|
||
|
*/
|
||
|
class NoSeekStreamTest extends BaseTest
|
||
|
{
|
||
|
/**
|
||
|
* @expectedException \RuntimeException
|
||
|
* @expectedExceptionMessage Cannot seek a NoSeekStream
|
||
|
*/
|
||
|
public function testCannotSeek()
|
||
|
{
|
||
|
$s = $this->getMockBuilder('Psr\Http\Message\StreamInterface')
|
||
|
->setMethods(['isSeekable', 'seek'])
|
||
|
->getMockForAbstractClass();
|
||
|
$s->expects($this->never())->method('seek');
|
||
|
$s->expects($this->never())->method('isSeekable');
|
||
|
$wrapped = new NoSeekStream($s);
|
||
|
$this->assertFalse($wrapped->isSeekable());
|
||
|
$wrapped->seek(2);
|
||
|
}
|
||
|
|
||
|
public function testToStringDoesNotSeek()
|
||
|
{
|
||
|
$s = \GuzzleHttp\Psr7\stream_for('foo');
|
||
|
$s->seek(1);
|
||
|
$wrapped = new NoSeekStream($s);
|
||
|
$this->assertEquals('oo', (string) $wrapped);
|
||
|
|
||
|
$wrapped->close();
|
||
|
}
|
||
|
}
|