You are here

public function FnStreamTest::testDecoratesStream in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/tests/FnStreamTest.php \GuzzleHttp\Tests\Psr7\FnStreamTest::testDecoratesStream()

File

vendor/guzzlehttp/psr7/tests/FnStreamTest.php, line 51

Class

FnStreamTest
@covers GuzzleHttp\Psr7\FnStream

Namespace

GuzzleHttp\Tests\Psr7

Code

public function testDecoratesStream() {
  $a = Psr7\stream_for('foo');
  $b = FnStream::decorate($a, []);
  $this
    ->assertEquals(3, $b
    ->getSize());
  $this
    ->assertEquals($b
    ->isWritable(), true);
  $this
    ->assertEquals($b
    ->isReadable(), true);
  $this
    ->assertEquals($b
    ->isSeekable(), true);
  $this
    ->assertEquals($b
    ->read(3), 'foo');
  $this
    ->assertEquals($b
    ->tell(), 3);
  $this
    ->assertEquals($a
    ->tell(), 3);
  $this
    ->assertSame('', $a
    ->read(1));
  $this
    ->assertEquals($b
    ->eof(), true);
  $this
    ->assertEquals($a
    ->eof(), true);
  $b
    ->seek(0);
  $this
    ->assertEquals('foo', (string) $b);
  $b
    ->seek(0);
  $this
    ->assertEquals('foo', $b
    ->getContents());
  $this
    ->assertEquals($a
    ->getMetadata(), $b
    ->getMetadata());
  $b
    ->seek(0, SEEK_END);
  $b
    ->write('bar');
  $this
    ->assertEquals('foobar', (string) $b);
  $this
    ->assertInternalType('resource', $b
    ->detach());
  $b
    ->close();
}