/**
  * @covers Guzzle\Common\Stream::read
  * @covers Guzzle\Common\Stream::write
  * @covers Guzzle\Common\Stream::seek
  * @covers Guzzle\Common\Stream::isReadable
  * @covers Guzzle\Common\Stream::isSeekable
  */
 public function testWrapsStream()
 {
     $handle = fopen('php://temp', 'w+');
     fwrite($handle, 'data');
     $stream = new Stream($handle);
     $this->assertTrue($stream->isSeekable());
     $this->assertTrue($stream->isReadable());
     $this->assertTrue($stream->seek(0));
     $this->assertEquals('da', $stream->read(2));
     $this->assertEquals('ta', $stream->read(2));
     $this->assertTrue($stream->seek(0));
     $this->assertEquals('data', $stream->read(4));
     $stream->write('_appended');
     $stream->seek(0);
     $this->assertEquals('data_appended', $stream->read(13));
 }
Ejemplo n.º 2
0
 /**
  * @covers Guzzle\Common\Stream::ftell
  */
 public function testProvidesStreamPosition()
 {
     $handle = fopen(__DIR__ . '/../../../bootstrap.php', 'r');
     $stream = new Stream($handle);
     $stream->read(2);
     $this->assertSame(ftell($handle), $stream->ftell());
     $this->assertEquals(2, $stream->ftell());
 }