diff --git a/composer.json b/composer.json index b797318..d58be2b 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=5.3", - "react/event-loop": "~0.4.0|~0.3.0", + "react/event-loop": "^0.4 || ^0.3.5", "react/promise": "~2.1|~1.2" } } diff --git a/tests/FunctionRejectTest.php b/tests/FunctionRejectTest.php index 1ecf319..6153fcc 100644 --- a/tests/FunctionRejectTest.php +++ b/tests/FunctionRejectTest.php @@ -13,6 +13,13 @@ public function testPromiseIsPendingWithoutRunningLoop() $this->expectPromisePending($promise); } + public function testPromiseExpiredIsPendingWithoutRunningLoop() + { + $promise = Timer\reject(-1, $this->loop); + + $this->expectPromisePending($promise); + } + public function testPromiseWillBeRejectedOnTimeout() { $promise = Timer\reject(0.01, $this->loop); @@ -22,6 +29,15 @@ public function testPromiseWillBeRejectedOnTimeout() $this->expectPromiseRejected($promise); } + public function testPromiseExpiredWillBeRejectedOnTimeout() + { + $promise = Timer\reject(-1, $this->loop); + + $this->loop->run(); + + $this->expectPromiseRejected($promise); + } + public function testCancelingPromiseWillRejectTimer() { $promise = Timer\reject(0.01, $this->loop); diff --git a/tests/FunctionResolveTest.php b/tests/FunctionResolveTest.php index 8f1b2af..63b70f4 100644 --- a/tests/FunctionResolveTest.php +++ b/tests/FunctionResolveTest.php @@ -13,6 +13,13 @@ public function testPromiseIsPendingWithoutRunningLoop() $this->expectPromisePending($promise); } + public function testPromiseExpiredIsPendingWithoutRunningLoop() + { + $promise = Timer\resolve(-1, $this->loop); + + $this->expectPromisePending($promise); + } + public function testPromiseWillBeResolvedOnTimeout() { $promise = Timer\resolve(0.01, $this->loop); @@ -22,6 +29,15 @@ public function testPromiseWillBeResolvedOnTimeout() $this->expectPromiseResolved($promise); } + public function testPromiseExpiredWillBeResolvedOnTimeout() + { + $promise = Timer\resolve(-1, $this->loop); + + $this->loop->run(); + + $this->expectPromiseResolved($promise); + } + public function testWillStartLoopTimer() { $loop = $this->getMock('React\EventLoop\LoopInterface'); diff --git a/tests/FunctionTimeoutTest.php b/tests/FunctionTimeoutTest.php index bd3d49c..cc8dcd8 100644 --- a/tests/FunctionTimeoutTest.php +++ b/tests/FunctionTimeoutTest.php @@ -16,6 +16,15 @@ public function testResolvedWillResolveRightAway() $this->expectPromiseResolved($promise); } + public function testResolvedExpiredWillResolveRightAway() + { + $promise = Promise\resolve(); + + $promise = Timer\timeout($promise, -1, $this->loop); + + $this->expectPromiseResolved($promise); + } + public function testResolvedWillNotStartTimer() { $promise = Promise\resolve();