Skip to content

Commit

Permalink
Merge pull request #134 from clue-labs/promise-v3
Browse files Browse the repository at this point in the history
Forward compatibility with upcoming Promise v3
  • Loading branch information
SimonFrings authored Sep 5, 2022
2 parents ddfc9b2 + 9ba4e58 commit 90e8340
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"clue/redis-protocol": "0.3.*",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"react/event-loop": "^1.2",
"react/promise": "^2.0 || ^1.1",
"react/promise-timer": "^1.8",
"react/socket": "^1.9"
"react/promise": "^3 || ^2.0 || ^1.1",
"react/promise-timer": "^1.9",
"react/socket": "^1.12"
},
"require-dev": {
"clue/block-react": "^1.1",
"clue/block-react": "^1.5",
"phpunit/phpunit": "^9.3 || ^7.5"
},
"autoload": {
Expand Down
20 changes: 10 additions & 10 deletions tests/RedisClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function testPingAfterPingWillNotStartIdleTimerWhenFirstPingResolves()

$this->redis->ping();
$this->redis->ping();
$deferred->resolve();
$deferred->resolve(null);
}

public function testPingAfterPingWillStartAndCancelIdleTimerWhenSecondPingStartsAfterFirstResolves()
Expand All @@ -242,14 +242,14 @@ public function testPingAfterPingWillStartAndCancelIdleTimerWhenSecondPingStarts
$this->loop->expects($this->once())->method('cancelTimer')->with($timer);

$this->redis->ping();
$deferred->resolve();
$deferred->resolve(null);
$this->redis->ping();
}

public function testPingFollowedByIdleTimerWillCloseUnderlyingConnectionWithoutCloseEvent()
{
$client = $this->createMock(StreamingClient::class);
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve());
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve(null));
$client->expects($this->once())->method('close');

$this->factory->expects($this->once())->method('createClient')->willReturn(\React\Promise\resolve($client));
Expand Down Expand Up @@ -312,7 +312,7 @@ public function testCloseAfterPingWillEmitCloseWithoutErrorWhenUnderlyingClientC
public function testCloseAfterPingWillCloseUnderlyingClientConnectionWhenAlreadyResolved()
{
$client = $this->createMock(StreamingClient::class);
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve());
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve(null));
$client->expects($this->once())->method('close');

$deferred = new Deferred();
Expand All @@ -337,7 +337,7 @@ public function testCloseAfterPingWillCancelIdleTimerWhenPingIsAlreadyResolved()
$this->loop->expects($this->once())->method('cancelTimer')->with($timer);

$this->redis->ping();
$deferred->resolve();
$deferred->resolve(null);
$this->redis->close();
}

Expand Down Expand Up @@ -414,7 +414,7 @@ public function testEmitsNoErrorEventWhenUnderlyingClientEmitsError()
$error = new \RuntimeException();

$client = $this->createMock(StreamingClient::class);
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve());
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve(null));

$deferred = new Deferred();
$this->factory->expects($this->once())->method('createClient')->willReturn($deferred->promise());
Expand All @@ -429,7 +429,7 @@ public function testEmitsNoErrorEventWhenUnderlyingClientEmitsError()
public function testEmitsNoCloseEventWhenUnderlyingClientEmitsClose()
{
$client = $this->createMock(StreamingClient::class);
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve());
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve(null));

$deferred = new Deferred();
$this->factory->expects($this->once())->method('createClient')->willReturn($deferred->promise());
Expand Down Expand Up @@ -463,7 +463,7 @@ public function testEmitsNoCloseEventButWillCancelIdleTimerWhenUnderlyingConnect
$this->redis->on('close', $this->expectCallableNever());

$this->redis->ping();
$deferred->resolve();
$deferred->resolve(null);

$this->assertTrue(is_callable($closeHandler));
$closeHandler();
Expand All @@ -473,7 +473,7 @@ public function testEmitsMessageEventWhenUnderlyingClientEmitsMessageForPubSubCh
{
$messageHandler = null;
$client = $this->createMock(StreamingClient::class);
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve());
$client->expects($this->once())->method('__call')->willReturn(\React\Promise\resolve(null));
$client->expects($this->any())->method('on')->willReturnCallback(function ($event, $callback) use (&$messageHandler) {
if ($event === 'message') {
$messageHandler = $callback;
Expand All @@ -495,7 +495,7 @@ public function testEmitsUnsubscribeAndPunsubscribeEventsWhenUnderlyingClientClo
{
$allHandler = null;
$client = $this->createMock(StreamingClient::class);
$client->expects($this->exactly(6))->method('__call')->willReturn(\React\Promise\resolve());
$client->expects($this->exactly(6))->method('__call')->willReturn(\React\Promise\resolve(null));
$client->expects($this->any())->method('on')->willReturnCallback(function ($event, $callback) use (&$allHandler) {
if (!isset($allHandler[$event])) {
$allHandler[$event] = $callback;
Expand Down

0 comments on commit 90e8340

Please sign in to comment.