6
6
use React \EventLoop \Loop ;
7
7
use React \Promise \Deferred ;
8
8
use React \Promise \PromiseInterface ;
9
- use function Clue \ React \Block \await ;
9
+ use function React \Async \await ;
10
10
use function React \Promise \Timer \timeout ;
11
11
12
12
class FunctionalTest extends TestCase
@@ -27,8 +27,8 @@ public function testPing(): void
27
27
{
28
28
$ redis = new RedisClient ($ this ->uri );
29
29
30
+ /** @var PromiseInterface<string> */
30
31
$ promise = $ redis ->ping ();
31
- $ this ->assertInstanceOf (PromiseInterface::class, $ promise );
32
32
33
33
$ ret = await ($ promise );
34
34
@@ -39,8 +39,8 @@ public function testPingLazy(): void
39
39
{
40
40
$ redis = new RedisClient ($ this ->uri );
41
41
42
+ /** @var PromiseInterface<string> */
42
43
$ promise = $ redis ->ping ();
43
- $ this ->assertInstanceOf (PromiseInterface::class, $ promise );
44
44
45
45
$ ret = await ($ promise );
46
46
@@ -77,6 +77,7 @@ public function testMgetIsNotInterpretedAsSubMessage(): void
77
77
78
78
$ redis ->mset ('message ' , 'message ' , 'channel ' , 'channel ' , 'payload ' , 'payload ' );
79
79
80
+ /** @var PromiseInterface<never> */
80
81
$ promise = $ redis ->mget ('message ' , 'channel ' , 'payload ' )->then ($ this ->expectCallableOnce ());
81
82
$ redis ->on ('message ' , $ this ->expectCallableNever ());
82
83
@@ -90,6 +91,8 @@ public function testPipeline(): void
90
91
$ redis ->set ('a ' , 1 )->then ($ this ->expectCallableOnceWith ('OK ' ));
91
92
$ redis ->incr ('a ' )->then ($ this ->expectCallableOnceWith (2 ));
92
93
$ redis ->incr ('a ' )->then ($ this ->expectCallableOnceWith (3 ));
94
+
95
+ /** @var PromiseInterface<void> */
93
96
$ promise = $ redis ->get ('a ' )->then ($ this ->expectCallableOnceWith ('3 ' ));
94
97
95
98
await ($ promise );
@@ -98,6 +101,8 @@ public function testPipeline(): void
98
101
public function testInvalidCommand (): void
99
102
{
100
103
$ redis = new RedisClient ($ this ->uri );
104
+
105
+ /** @var PromiseInterface<never> */
101
106
$ promise = $ redis ->doesnotexist (1 , 2 , 3 );
102
107
103
108
$ this ->expectException (\Exception::class);
@@ -108,6 +113,8 @@ public function testMultiExecEmpty(): void
108
113
{
109
114
$ redis = new RedisClient ($ this ->uri );
110
115
$ redis ->multi ()->then ($ this ->expectCallableOnceWith ('OK ' ));
116
+
117
+ /** @var PromiseInterface<void> */
111
118
$ promise = $ redis ->exec ()->then ($ this ->expectCallableOnceWith ([]));
112
119
113
120
await ($ promise );
@@ -122,6 +129,8 @@ public function testMultiExecQueuedExecHasValues(): void
122
129
$ redis ->expire ('b ' , 20 )->then ($ this ->expectCallableOnceWith ('QUEUED ' ));
123
130
$ redis ->incrBy ('b ' , 2 )->then ($ this ->expectCallableOnceWith ('QUEUED ' ));
124
131
$ redis ->ttl ('b ' )->then ($ this ->expectCallableOnceWith ('QUEUED ' ));
132
+
133
+ /** @var PromiseInterface<void> */
125
134
$ promise = $ redis ->exec ()->then ($ this ->expectCallableOnceWith (['OK ' , 1 , 12 , 20 ]));
126
135
127
136
await ($ promise );
@@ -135,6 +144,7 @@ public function testPubSub(): void
135
144
$ channel = 'channel:test: ' . mt_rand ();
136
145
137
146
// consumer receives a single message
147
+ /** @var Deferred<void> */
138
148
$ deferred = new Deferred ();
139
149
$ consumer ->on ('message ' , $ this ->expectCallableOnce ());
140
150
$ consumer ->on ('message ' , [$ deferred , 'resolve ' ]);
@@ -148,7 +158,9 @@ public function testPubSub(): void
148
158
149
159
await (timeout ($ deferred ->promise (), 0.1 ));
150
160
151
- await ($ consumer ->unsubscribe ($ channel ));
161
+ /** @var PromiseInterface<array{0:"unsubscribe",1:string,2:0}> */
162
+ $ promise = $ consumer ->unsubscribe ($ channel );
163
+ await ($ promise );
152
164
}
153
165
154
166
public function testClose (): void
0 commit comments