You are here

public function PumpStreamTest::testStoresExcessDataInBuffer in Zircon Profile 8

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

File

vendor/guzzlehttp/psr7/tests/PumpStreamTest.php, line 33

Class

PumpStreamTest

Namespace

GuzzleHttp\Tests\Psr7

Code

public function testStoresExcessDataInBuffer() {
  $called = [];
  $p = Psr7\stream_for(function ($size) use (&$called) {
    $called[] = $size;
    return 'abcdef';
  });
  $this
    ->assertEquals('a', $p
    ->read(1));
  $this
    ->assertEquals('b', $p
    ->read(1));
  $this
    ->assertEquals('cdef', $p
    ->read(4));
  $this
    ->assertEquals('abcdefabc', $p
    ->read(9));
  $this
    ->assertEquals([
    1,
    9,
    3,
  ], $called);
}