예제 #1
0
 public function testAllowsBoundedSeek()
 {
     $this->body->seek(100);
     $this->assertEquals(13, $this->decorated->tell());
     $this->body->seek(0);
     $this->assertEquals(0, $this->body->tell());
     $this->assertEquals(3, $this->decorated->tell());
     $this->assertEquals(false, $this->body->seek(1000, SEEK_END));
 }
예제 #2
0
 public function testCanDetachAndAttachStream()
 {
     $r = fopen('php://temp', 'w+');
     $stream = new Stream($r);
     $stream->write('foo');
     $this->assertTrue($stream->isReadable());
     $this->assertSame($r, $stream->detach());
     $this->assertNull($stream->detach());
     $this->assertFalse($stream->isReadable());
     $this->assertFalse($stream->read(10));
     $this->assertFalse($stream->isWritable());
     $this->assertFalse($stream->write('bar'));
     $this->assertFalse($stream->isSeekable());
     $this->assertFalse($stream->seek(10));
     $this->assertFalse($stream->tell());
     $this->assertTrue($stream->eof());
     $this->assertNull($stream->getSize());
     $this->assertSame('', (string) $stream);
     $this->assertSame('', $stream->getContents());
     $stream->attach($r);
     $stream->seek(0);
     $this->assertEquals('foo', $stream->getContents());
     $this->assertTrue($stream->isReadable());
     $this->assertTrue($stream->isWritable());
     $this->assertTrue($stream->isSeekable());
     $stream->close();
 }
예제 #3
0
 public function testProvidesStreamPosition()
 {
     $handle = fopen('php://temp', 'w+');
     $stream = new Stream($handle);
     $this->assertEquals(0, $stream->tell());
     $stream->write('foo');
     $this->assertEquals(3, $stream->tell());
     $stream->seek(1);
     $this->assertEquals(1, $stream->tell());
     $this->assertSame(ftell($handle), $stream->tell());
     $stream->close();
 }