updated plugin W3 Total Cache
version 2.3.3
This commit is contained in:
71
wp-content/plugins/w3-total-cache/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php
vendored
Normal file
71
wp-content/plugins/w3-total-cache/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Tests\Psr7;
|
||||
|
||||
use GuzzleHttp\Psr7\LazyOpenStream;
|
||||
|
||||
class LazyOpenStreamTest extends BaseTest
|
||||
{
|
||||
private $fname;
|
||||
|
||||
/**
|
||||
* @before
|
||||
*/
|
||||
public function setUpTest()
|
||||
{
|
||||
$this->fname = tempnam(sys_get_temp_dir(), 'tfile');
|
||||
|
||||
if (file_exists($this->fname)) {
|
||||
unlink($this->fname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @after
|
||||
*/
|
||||
public function tearDownTest()
|
||||
{
|
||||
if (file_exists($this->fname)) {
|
||||
unlink($this->fname);
|
||||
}
|
||||
}
|
||||
|
||||
public function testOpensLazily()
|
||||
{
|
||||
$l = new LazyOpenStream($this->fname, 'w+');
|
||||
$l->write('foo');
|
||||
$this->assertInternalTypeGuzzle('array', $l->getMetadata());
|
||||
self::assertFileExists($this->fname);
|
||||
self::assertSame('foo', file_get_contents($this->fname));
|
||||
self::assertSame('foo', (string) $l);
|
||||
}
|
||||
|
||||
public function testProxiesToFile()
|
||||
{
|
||||
file_put_contents($this->fname, 'foo');
|
||||
$l = new LazyOpenStream($this->fname, 'r');
|
||||
self::assertSame('foo', $l->read(4));
|
||||
self::assertTrue($l->eof());
|
||||
self::assertSame(3, $l->tell());
|
||||
self::assertTrue($l->isReadable());
|
||||
self::assertTrue($l->isSeekable());
|
||||
self::assertFalse($l->isWritable());
|
||||
$l->seek(1);
|
||||
self::assertSame('oo', $l->getContents());
|
||||
self::assertSame('foo', (string) $l);
|
||||
self::assertSame(3, $l->getSize());
|
||||
$this->assertInternalTypeGuzzle('array', $l->getMetadata());
|
||||
$l->close();
|
||||
}
|
||||
|
||||
public function testDetachesUnderlyingStream()
|
||||
{
|
||||
file_put_contents($this->fname, 'foo');
|
||||
$l = new LazyOpenStream($this->fname, 'r');
|
||||
$r = $l->detach();
|
||||
$this->assertInternalTypeGuzzle('resource', $r);
|
||||
fseek($r, 0);
|
||||
self::assertSame('foo', stream_get_contents($r));
|
||||
fclose($r);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user