public function StreamWrapperTest::testResource in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php \GuzzleHttp\Tests\Psr7\StreamWrapperTest::testResource()
File
- vendor/
guzzlehttp/ psr7/ tests/ StreamWrapperTest.php, line 12
Class
Namespace
GuzzleHttp\Tests\Psr7Code
public function testResource() {
$stream = Psr7\stream_for('foo');
$handle = StreamWrapper::getResource($stream);
$this
->assertSame('foo', fread($handle, 3));
$this
->assertSame(3, ftell($handle));
$this
->assertSame(3, fwrite($handle, 'bar'));
$this
->assertSame(0, fseek($handle, 0));
$this
->assertSame('foobar', fread($handle, 6));
$this
->assertSame('', fread($handle, 1));
$this
->assertTrue(feof($handle));
// This fails on HHVM for some reason
if (!defined('HHVM_VERSION')) {
$this
->assertEquals([
'dev' => 0,
'ino' => 0,
'mode' => 33206,
'nlink' => 0,
'uid' => 0,
'gid' => 0,
'rdev' => 0,
'size' => 6,
'atime' => 0,
'mtime' => 0,
'ctime' => 0,
'blksize' => 0,
'blocks' => 0,
0 => 0,
1 => 0,
2 => 33206,
3 => 0,
4 => 0,
5 => 0,
6 => 0,
7 => 6,
8 => 0,
9 => 0,
10 => 0,
11 => 0,
12 => 0,
], fstat($handle));
}
$this
->assertTrue(fclose($handle));
$this
->assertSame('foobar', (string) $stream);
}