Skip to content

Commit 66c0301

Browse files
committed
cleanup spec
1 parent 98909ce commit 66c0301

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

spec/async.spec.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Exception;
66
use React\EventLoop\Factory;
7-
use React\EventLoop\LoopInterface;
87
use React\Promise\Promise;
98
use function React\Promise\all;
109
use function React\Promise\race;
@@ -14,8 +13,6 @@
1413
describe('async', function () {
1514
describe('with simple promise', function () {
1615
it('should return promise with value', function () {
17-
$resultValue = null;
18-
1916
asyncRun(function () {
2017
return yield resolve('val');
2118
})->then(function ($res) {
@@ -82,7 +79,7 @@
8279
});
8380
describe('with loop', function () {
8481
given('loop', function () {
85-
return $loop = Factory::create();
82+
return Factory::create();
8683
});
8784
given('wait', function () {
8885
return function ($time) {
@@ -98,13 +95,11 @@
9895
});
9996

10097
it('should work fine with loop based promises', function () {
101-
/** @var LoopInterface $loop */
102-
$loop = $this->loop;
103-
10498
$this->time = microtime(true);
10599
$onResolve = function ($res) {
106100
$this->result = $res;
107101
$this->time = microtime(true) - $this->time;
102+
$this->loop->stop();
108103
};
109104
$onReject = function ($reason) {
110105
};
@@ -128,11 +123,7 @@
128123
};
129124
async($async("initial value"))->then($onResolve, $onReject);
130125

131-
$loop->addTimer(0.41, function () use ($loop) {
132-
$loop->stop();
133-
});
134-
135-
$loop->run();
126+
$this->loop->run();
136127
expect($this->result)->toBe('wow');
137128
expect($this->time)->toBeGreaterThan(0.4);
138129
expect($this->time)->toBeLessThan(0.41);

0 commit comments

Comments
 (0)