Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward compatibility with upcoming Promise v3 #134

Merged
merged 1 commit into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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