p2 project
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

2 months ago
<?php
declare(strict_types=1);
namespace GuzzleHttp\Tests\Psr7;
use GuzzleHttp\Psr7\NoSeekStream;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\StreamInterface;
/**
* @covers \GuzzleHttp\Psr7\NoSeekStream
* @covers \GuzzleHttp\Psr7\StreamDecoratorTrait
*/
class NoSeekStreamTest extends TestCase
{
public function testCannotSeek(): void
{
$s = $this->createMock(StreamInterface::class);
$s->expects(self::never())->method('seek');
$s->expects(self::never())->method('isSeekable');
$wrapped = new NoSeekStream($s);
self::assertFalse($wrapped->isSeekable());
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Cannot seek a NoSeekStream');
$wrapped->seek(2);
}
public function testToStringDoesNotSeek(): void
{
$s = \GuzzleHttp\Psr7\Utils::streamFor('foo');
$s->seek(1);
$wrapped = new NoSeekStream($s);
self::assertSame('oo', (string) $wrapped);
$wrapped->close();
}
}