summaryrefslogtreecommitdiff
path: root/server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php
diff options
context:
space:
mode:
authorLoic GUEGAN <loic@Manzerbredes>2016-01-23 14:37:24 +0100
committerLoic GUEGAN <loic@Manzerbredes>2016-01-23 14:37:24 +0100
commit189f7a9ef4c6265dbac232e5c5685aebbbfc7c53 (patch)
treed397facc1e45cee4713ea95b0eaa4ffa9cbf0921 /server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php
parent2984adf171c49940e683fa997e8cdc60fcf1d60b (diff)
parenta44cc1d2e3c0f147e91a5c052ac7fd879e34e706 (diff)
Merge branch 'develop' of github.com:manzerbredes/istic-openstack into develop
Diffstat (limited to 'server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php')
-rw-r--r--server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php b/server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php
new file mode 100644
index 0000000..7358bb6
--- /dev/null
+++ b/server/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php
@@ -0,0 +1,72 @@
+<?php
+namespace GuzzleHttp\Tests\Psr7;
+
+use GuzzleHttp\Psr7\LimitStream;
+use GuzzleHttp\Psr7\PumpStream;
+use GuzzleHttp\Psr7;
+
+class PumpStreamTest extends \PHPUnit_Framework_TestCase
+{
+ public function testHasMetadataAndSize()
+ {
+ $p = new PumpStream(function () {}, [
+ 'metadata' => ['foo' => 'bar'],
+ 'size' => 100
+ ]);
+
+ $this->assertEquals('bar', $p->getMetadata('foo'));
+ $this->assertEquals(['foo' => 'bar'], $p->getMetadata());
+ $this->assertEquals(100, $p->getSize());
+ }
+
+ public function testCanReadFromCallable()
+ {
+ $p = Psr7\stream_for(function ($size) {
+ return 'a';
+ });
+ $this->assertEquals('a', $p->read(1));
+ $this->assertEquals(1, $p->tell());
+ $this->assertEquals('aaaaa', $p->read(5));
+ $this->assertEquals(6, $p->tell());
+ }
+
+ public function testStoresExcessDataInBuffer()
+ {
+ $called = [];
+ $p = Psr7\stream_for(function ($size) use (&$called) {
+ $called[] = $size;
+ return 'abcdef';
+ });
+ $this->assertEquals('a', $p->read(1));
+ $this->assertEquals('b', $p->read(1));
+ $this->assertEquals('cdef', $p->read(4));
+ $this->assertEquals('abcdefabc', $p->read(9));
+ $this->assertEquals([1, 9, 3], $called);
+ }
+
+ public function testInifiniteStreamWrappedInLimitStream()
+ {
+ $p = Psr7\stream_for(function () { return 'a'; });
+ $s = new LimitStream($p, 5);
+ $this->assertEquals('aaaaa', (string) $s);
+ }
+
+ public function testDescribesCapabilities()
+ {
+ $p = Psr7\stream_for(function () {});
+ $this->assertTrue($p->isReadable());
+ $this->assertFalse($p->isSeekable());
+ $this->assertFalse($p->isWritable());
+ $this->assertNull($p->getSize());
+ $this->assertEquals('', $p->getContents());
+ $this->assertEquals('', (string) $p);
+ $p->close();
+ $this->assertEquals('', $p->read(10));
+ $this->assertTrue($p->eof());
+
+ try {
+ $this->assertFalse($p->write('aa'));
+ $this->fail();
+ } catch (\RuntimeException $e) {}
+ }
+}