You are here

public function LimitStreamTest::testAllowsBoundedSeek in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/psr7/tests/LimitStreamTest.php \GuzzleHttp\Tests\Psr7\LimitStreamTest::testAllowsBoundedSeek()

File

vendor/guzzlehttp/psr7/tests/LimitStreamTest.php, line 75

Class

LimitStreamTest
@covers GuzzleHttp\Psr7\LimitStream

Namespace

GuzzleHttp\Tests\Psr7

Code

public function testAllowsBoundedSeek() {
  $this->body
    ->seek(100);
  $this
    ->assertEquals(10, $this->body
    ->tell());
  $this
    ->assertEquals(13, $this->decorated
    ->tell());
  $this->body
    ->seek(0);
  $this
    ->assertEquals(0, $this->body
    ->tell());
  $this
    ->assertEquals(3, $this->decorated
    ->tell());
  try {
    $this->body
      ->seek(-10);
    $this
      ->fail();
  } catch (\RuntimeException $e) {
  }
  $this
    ->assertEquals(0, $this->body
    ->tell());
  $this
    ->assertEquals(3, $this->decorated
    ->tell());
  $this->body
    ->seek(5);
  $this
    ->assertEquals(5, $this->body
    ->tell());
  $this
    ->assertEquals(8, $this->decorated
    ->tell());

  // Fail
  try {
    $this->body
      ->seek(1000, SEEK_END);
    $this
      ->fail();
  } catch (\RuntimeException $e) {
  }
}