Skip to content

Commit

Permalink
add connections test (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon authored Feb 29, 2024
1 parent 671c1a4 commit 2877752
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Laravel\Reverb\Tests\ReverbTestCase;

use function React\Async\await;

uses(ReverbTestCase::class);

it('can return a connection count', function () {
subscribe('test-channel-one');
subscribe('presence-test-channel-two');

$response = await($this->signedRequest('connections'));

expect($response->getStatusCode())->toBe(200);
expect($response->getBody()->getContents())->toBe('{"connections":2}');
});

it('can return the correct connection count when subscribed to multiple channels', function () {
$connection = connect();
subscribe('test-channel-one', connection: $connection);
subscribe('presence-test-channel-two', connection: $connection);

$response = await($this->signedRequest('connections'));

expect($response->getStatusCode())->toBe(200);
expect($response->getBody()->getContents())->toBe('{"connections":1}');
});

0 comments on commit 2877752

Please sign in to comment.