Example #1
0
 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) {
     }
 }
Example #2
0
 public function testCloseClearProperties()
 {
     $handle = fopen('php://temp', 'r+');
     $stream = new Stream($handle);
     $stream->close();
     $this->assertFalse($stream->isSeekable());
     $this->assertFalse($stream->isReadable());
     $this->assertFalse($stream->isWritable());
     $this->assertNull($stream->getSize());
     $this->assertEmpty($stream->getMetadata());
 }