Skip to content

Commit 9cae74a

Browse files
committed
Update to use reactphp/async instead of clue/reactphp-block
1 parent 579169d commit 9cae74a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"react/socket": "dev-cancel-happy as 1.15.0"
2121
},
2222
"require-dev": {
23-
"clue/block-react": "^1.5",
2423
"phpstan/phpstan": "1.10.15 || 1.4.10",
25-
"phpunit/phpunit": "^9.6 || ^7.5"
24+
"phpunit/phpunit": "^9.6 || ^7.5",
25+
"react/async": "^4.2 || ^3.2"
2626
},
2727
"autoload": {
2828
"psr-4": { "Clue\\React\\Redis\\": "src/" }

tests/FunctionalTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use React\EventLoop\Loop;
77
use React\Promise\Deferred;
88
use React\Promise\PromiseInterface;
9-
use function Clue\React\Block\await;
9+
use function React\Async\await;
1010
use function React\Promise\Timer\timeout;
1111

1212
class FunctionalTest extends TestCase
@@ -27,8 +27,8 @@ public function testPing(): void
2727
{
2828
$redis = new RedisClient($this->uri);
2929

30+
/** @var PromiseInterface<string> */
3031
$promise = $redis->ping();
31-
$this->assertInstanceOf(PromiseInterface::class, $promise);
3232

3333
$ret = await($promise);
3434

@@ -39,8 +39,8 @@ public function testPingLazy(): void
3939
{
4040
$redis = new RedisClient($this->uri);
4141

42+
/** @var PromiseInterface<string> */
4243
$promise = $redis->ping();
43-
$this->assertInstanceOf(PromiseInterface::class, $promise);
4444

4545
$ret = await($promise);
4646

@@ -77,6 +77,7 @@ public function testMgetIsNotInterpretedAsSubMessage(): void
7777

7878
$redis->mset('message', 'message', 'channel', 'channel', 'payload', 'payload');
7979

80+
/** @var PromiseInterface<never> */
8081
$promise = $redis->mget('message', 'channel', 'payload')->then($this->expectCallableOnce());
8182
$redis->on('message', $this->expectCallableNever());
8283

@@ -90,6 +91,8 @@ public function testPipeline(): void
9091
$redis->set('a', 1)->then($this->expectCallableOnceWith('OK'));
9192
$redis->incr('a')->then($this->expectCallableOnceWith(2));
9293
$redis->incr('a')->then($this->expectCallableOnceWith(3));
94+
95+
/** @var PromiseInterface<void> */
9396
$promise = $redis->get('a')->then($this->expectCallableOnceWith('3'));
9497

9598
await($promise);
@@ -98,6 +101,8 @@ public function testPipeline(): void
98101
public function testInvalidCommand(): void
99102
{
100103
$redis = new RedisClient($this->uri);
104+
105+
/** @var PromiseInterface<never> */
101106
$promise = $redis->doesnotexist(1, 2, 3);
102107

103108
$this->expectException(\Exception::class);
@@ -108,6 +113,8 @@ public function testMultiExecEmpty(): void
108113
{
109114
$redis = new RedisClient($this->uri);
110115
$redis->multi()->then($this->expectCallableOnceWith('OK'));
116+
117+
/** @var PromiseInterface<void> */
111118
$promise = $redis->exec()->then($this->expectCallableOnceWith([]));
112119

113120
await($promise);
@@ -122,6 +129,8 @@ public function testMultiExecQueuedExecHasValues(): void
122129
$redis->expire('b', 20)->then($this->expectCallableOnceWith('QUEUED'));
123130
$redis->incrBy('b', 2)->then($this->expectCallableOnceWith('QUEUED'));
124131
$redis->ttl('b')->then($this->expectCallableOnceWith('QUEUED'));
132+
133+
/** @var PromiseInterface<void> */
125134
$promise = $redis->exec()->then($this->expectCallableOnceWith(['OK', 1, 12, 20]));
126135

127136
await($promise);
@@ -135,6 +144,7 @@ public function testPubSub(): void
135144
$channel = 'channel:test:' . mt_rand();
136145

137146
// consumer receives a single message
147+
/** @var Deferred<void> */
138148
$deferred = new Deferred();
139149
$consumer->on('message', $this->expectCallableOnce());
140150
$consumer->on('message', [$deferred, 'resolve']);
@@ -148,7 +158,9 @@ public function testPubSub(): void
148158

149159
await(timeout($deferred->promise(), 0.1));
150160

151-
await($consumer->unsubscribe($channel));
161+
/** @var PromiseInterface<array{0:"unsubscribe",1:string,2:0}> */
162+
$promise = $consumer->unsubscribe($channel);
163+
await($promise);
152164
}
153165

154166
public function testClose(): void

0 commit comments

Comments
 (0)