From 23d720fbb1a33ea94fb7fde0a73ecf57f14857b4 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Tue, 25 Dec 2018 12:59:12 +0100 Subject: [PATCH] Add test case for #47 --- docs/.shared | 2 +- middle | 0 test/ResourceStreamTest.php | 26 ++++++++++++++++++++++++-- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 middle diff --git a/docs/.shared b/docs/.shared index bd32eb0..cb9279c 160000 --- a/docs/.shared +++ b/docs/.shared @@ -1 +1 @@ -Subproject commit bd32eb0458ad2f1f66b322a816e0cb8341e3f806 +Subproject commit cb9279c84cea4128da664ed34d4a7d4d3ebc9279 diff --git a/middle b/middle new file mode 100644 index 0000000..e69de29 diff --git a/test/ResourceStreamTest.php b/test/ResourceStreamTest.php index c5c40b0..3e13210 100644 --- a/test/ResourceStreamTest.php +++ b/test/ResourceStreamTest.php @@ -71,7 +71,8 @@ class ResourceStreamTest extends TestCase Loop::run(function () { try { /* prevent crashes with phpdbg due to SIGPIPE not being handled... */ - Loop::onSignal(\defined("SIGPIPE") ? SIGPIPE : 13, function () {}); + Loop::onSignal(\defined("SIGPIPE") ? SIGPIPE : 13, function () { + }); } catch (Loop\UnsupportedFeatureException $e) { } @@ -94,7 +95,8 @@ class ResourceStreamTest extends TestCase Loop::run(function () { try { /* prevent crashes with phpdbg due to SIGPIPE not being handled... */ - Loop::onSignal(\defined("SIGPIPE") ? SIGPIPE : 13, function () {}); + Loop::onSignal(\defined("SIGPIPE") ? SIGPIPE : 13, function () { + }); } catch (Loop\UnsupportedFeatureException $e) { } @@ -249,4 +251,24 @@ class ResourceStreamTest extends TestCase $this->assertSame($message, $received); }); } + + public function testIssue47() + { + Loop::run(function () { + $middle = \tempnam(\sys_get_temp_dir(), 'byte-stream-middle-'); + + \Amp\ByteStream\pipe( + new ResourceInputStream(fopen(__FILE__, 'rb')), + new ResourceOutputStream(fopen($middle, 'wb')) + ); + + $middleReadStream = new ResourceInputStream(fopen($middle, 'rb')); + + while (null !== $chunk = yield $middleReadStream->read()) { + unset($chunk); + } + + $this->assertTrue(true); + }); + } }