From 198ebb60f7a5472f1392372344fe14b5fa85a5a8 Mon Sep 17 00:00:00 2001 From: PJ Dietz Date: Sun, 16 Aug 2020 12:08:57 -0400 Subject: [PATCH] Fix broken test for Stream --- test/src/StreamHelper.php | 35 ++++++++++++++++++++++++++ test/tests/unit/Message/StreamTest.php | 13 +++++++--- 2 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 test/src/StreamHelper.php diff --git a/test/src/StreamHelper.php b/test/src/StreamHelper.php new file mode 100644 index 0000000..cf6e280 --- /dev/null +++ b/test/src/StreamHelper.php @@ -0,0 +1,35 @@ +resource = fopen("php://memory", "w+"); $this->resourceDevNull = fopen("/dev/null", "r"); fwrite($this->resource, $this->content); + StreamHelper::$fail = false; } public function tearDown(): void @@ -106,7 +110,8 @@ class StreamTest extends TestCase public function testTellThrowsRuntimeExceptionWhenUnableToReadStreamPosition() { - $stream = new Stream($this->resourceDevNull); + StreamHelper::$fail = true; + $stream = new Stream($this->resource); $this->expectException(RuntimeException::class); $stream->tell(); } @@ -136,7 +141,8 @@ class StreamTest extends TestCase public function testSeekThrowsRuntimeExceptionWhenUnableToSeek() { - $stream = new Stream($this->resourceDevNull); + StreamHelper::$fail = true; + $stream = new Stream($this->resource); $this->expectException(RuntimeException::class); $stream->seek(10); } @@ -151,7 +157,8 @@ class StreamTest extends TestCase public function testRewindThrowsRuntimeExceptionWhenUnableToRewind() { - $stream = new Stream($this->resourceDevNull); + StreamHelper::$fail = true; + $stream = new Stream($this->resource); $this->expectException(RuntimeException::class); $stream->rewind(); }