Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Dec 8, 2024
1 parent 0e833a1 commit 291915a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/Servers/Reverb/Publishing/RedisPubSubProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ public function __construct(
*/
public function connect(LoopInterface $loop): void
{
$this->subscribingClient = new RedisClient(
$this->publishingClient = new RedisClient(
$loop,
$this->clientFactory,
$this->channel,
'subscriber',
$this->server,
fn () => $this->subscribe()
'publisher',
$this->server
);
$this->subscribingClient->connect();
$this->publishingClient->connect();

$this->publishingClient = new RedisClient(
$this->subscribingClient = new RedisClient(
$loop,
$this->clientFactory,
$this->channel,
'publisher',
$this->server
'subscriber',
$this->server,
fn () => $this->subscribe()
);
$this->publishingClient->connect();
$this->subscribingClient->connect();
}

/**
Expand Down
13 changes: 8 additions & 5 deletions tests/Unit/Servers/Reverb/Publishing/RedisPubSubProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Laravel\Reverb\Servers\Reverb\Publishing\RedisClientFactory;
use Laravel\Reverb\Servers\Reverb\Publishing\RedisPubSubProvider;
use React\EventLoop\LoopInterface;
use React\Promise\Promise;

it('resubscribes to the scaling channel on unsubscribe event', function () {
$channel = 'reverb';
Expand All @@ -21,6 +22,10 @@
->with('message', Mockery::any())
->zeroOrMoreTimes();

$subscribingClient->shouldReceive('on')
->with('close', Mockery::any())
->zeroOrMoreTimes();

$subscribingClient->shouldReceive('subscribe')
->twice()
->with($channel);
Expand All @@ -30,17 +35,15 @@
// The first call to make() will return a publishing client
$clientFactory->shouldReceive('make')
->once()
->andReturn(Mockery::mock(Client::class));
->andReturn(new Promise(fn (callable $resolve) => $resolve));

$clientFactory->shouldReceive('make')
->once()
->andReturn($subscribingClient);
->andReturn(new Promise(fn (callable $resolve) => $resolve($subscribingClient)));

$provider = new RedisPubSubProvider($clientFactory, Mockery::mock(PubSubIncomingMessageHandler::class), $channel);
$provider->connect(Mockery::mock(LoopInterface::class));

$provider->subscribe();
})->skip();
});

it('can successfully reconnect', function () {})->todo();

Expand Down

0 comments on commit 291915a

Please sign in to comment.