diff --git a/src/functions.php b/src/functions.php index 43665b2..474667d 100644 --- a/src/functions.php +++ b/src/functions.php @@ -236,7 +236,7 @@ function sleep($time, LoopInterface $loop = null) return new Promise(function ($resolve) use ($loop, $time, &$timer) { // resolve the promise when the timer fires in $time seconds $timer = $loop->addTimer($time, function () use ($resolve) { - $resolve(); + $resolve(null); }); }, function () use (&$timer, $loop) { // cancelling this promise will cancel the timer, clean the reference diff --git a/tests/FunctionTimeoutTest.php b/tests/FunctionTimeoutTest.php index b66cf6e..b794fe7 100644 --- a/tests/FunctionTimeoutTest.php +++ b/tests/FunctionTimeoutTest.php @@ -10,7 +10,7 @@ class FunctionTimeoutTest extends TestCase { public function testResolvedWillResolveRightAway() { - $promise = Promise\resolve(); + $promise = Promise\resolve(null); $promise = Timer\timeout($promise, 3); @@ -19,7 +19,7 @@ public function testResolvedWillResolveRightAway() public function testResolvedExpiredWillResolveRightAway() { - $promise = Promise\resolve(); + $promise = Promise\resolve(null); $promise = Timer\timeout($promise, -1); @@ -28,7 +28,7 @@ public function testResolvedExpiredWillResolveRightAway() public function testResolvedWillNotStartTimer() { - $promise = Promise\resolve(); + $promise = Promise\resolve(null); Timer\timeout($promise, 3); @@ -139,7 +139,9 @@ public function testCancelTimeoutWillCancelGivenPromise() public function testCancelGivenPromiseWillReject() { - $promise = new \React\Promise\Promise(function () { }, function ($resolve, $reject) { $reject(); }); + $promise = new \React\Promise\Promise(function () { }, function () { + throw new \RuntimeException(); + }); $timeout = Timer\timeout($promise, 0.01); @@ -151,7 +153,9 @@ public function testCancelGivenPromiseWillReject() public function testCancelTimeoutWillRejectIfGivenPromiseWillReject() { - $promise = new \React\Promise\Promise(function () { }, function ($resolve, $reject) { $reject(); }); + $promise = new \React\Promise\Promise(function () { }, function () { + throw new \RuntimeException(); + }); $timeout = Timer\timeout($promise, 0.01); @@ -163,7 +167,9 @@ public function testCancelTimeoutWillRejectIfGivenPromiseWillReject() public function testCancelTimeoutWillResolveIfGivenPromiseWillResolve() { - $promise = new \React\Promise\Promise(function () { }, function ($resolve, $reject) { $resolve(); }); + $promise = new \React\Promise\Promise(function () { }, function ($resolve) { + $resolve(null); + }); $timeout = Timer\timeout($promise, 0.01);