From 4442f6cd33d1eb5ace2f0ec23ae295b8b471eded Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Tue, 14 Mar 2017 22:05:19 +0100 Subject: [PATCH] Add test for Producer being already resolved --- test/ProducerTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/ProducerTest.php b/test/ProducerTest.php index c4ae41d..7b79f0c 100644 --- a/test/ProducerTest.php +++ b/test/ProducerTest.php @@ -181,4 +181,22 @@ class ProducerTest extends TestCase { $this->assertSame($exception, $caught); } } + + public function testListenAfterResolve() { + $invoked = false; + + Loop::run(function () use (&$invoked) { + $producer = new Producer(function (callable $emit) use (&$invoked) { + yield $emit(1); + }); + + yield $producer; + + $producer->listen(function () use (&$invoked) { + $invoked = true; + }); + }); + + $this->assertFalse($invoked); + } }