diff --git a/composer.json b/composer.json index f02e950..71d7330 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,8 @@ "amphp/phpunit-util": "^1", "phpunit/phpunit": "^6", "friendsofphp/php-cs-fixer": "^2.3", - "amphp/php-cs-fixer-config": "dev-master" + "amphp/php-cs-fixer-config": "dev-master", + "infection/infection": "^0.9.3" }, "autoload": { "psr-4": { diff --git a/infection.json.dist b/infection.json.dist new file mode 100644 index 0000000..e11b331 --- /dev/null +++ b/infection.json.dist @@ -0,0 +1,11 @@ +{ + "timeout": 5, + "source": { + "directories": [ + "lib" + ] + }, + "logs": { + "text": "infection.log" + } +} \ No newline at end of file diff --git a/test/MessageTest.php b/test/MessageTest.php index 9c0ee58..95e9ed0 100644 --- a/test/MessageTest.php +++ b/test/MessageTest.php @@ -255,4 +255,27 @@ class MessageTest extends TestCase $stream->read(); }); } + + public function testFalsyValueInStreamWhenBuffering() + { + Loop::run(function () { + $emitter = new Emitter; + $emitter->emit("0"); + $emitter->complete(); + $message = new Message(new IteratorStream($emitter->iterate())); + + $this->assertSame("0", yield $message); + }); + } + + public function testFalsyValueInStreamWhenStreaming() + { + Loop::run(function () { + $emitter = new Emitter; + $emitter->emit("0"); + $message = new Message(new IteratorStream($emitter->iterate())); + + $this->assertSame("0", yield $message->read()); + }); + } } diff --git a/test/PendingReadErrorTest.php b/test/PendingReadErrorTest.php new file mode 100644 index 0000000..7445dd8 --- /dev/null +++ b/test/PendingReadErrorTest.php @@ -0,0 +1,16 @@ +assertSame(0, (new PendingReadError)->getCode()); + } +} diff --git a/test/PipeTest.php b/test/PipeTest.php new file mode 100644 index 0000000..ad9982e --- /dev/null +++ b/test/PipeTest.php @@ -0,0 +1,25 @@ +assertSame(6, wait(pipe($stream, $buffer))); + + $buffer->end(); + $this->assertSame("abcdef", wait($buffer)); + } +}