Skip to content

Commit

Permalink
test content-length
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Apr 23, 2024
1 parent 3e0ca9b commit 11cbaa8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Feature/Protocols/Pusher/Reverb/ChannelControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":1}');
});

it('can send the content-length header', function () {
subscribe('test-channel-one');
subscribe('test-channel-one');

$response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache'));

expect($response->getHeader('Content-Length'))->toBe(['40']);
});

it('can gather data for a single channel', function () {
$this->usingRedis();

Expand Down Expand Up @@ -121,3 +130,14 @@
expect($response->getStatusCode())->toBe(200);
expect($response->getBody()->getContents())->toBe('{"occupied":true,"subscription_count":1}');
});

it('can send the content-length header when gathering results', function () {
$this->usingRedis();

subscribe('test-channel-one');
subscribe('test-channel-one');

$response = await($this->signedRequest('channels/test-channel-one?info=user_count,subscription_count,cache'));

expect($response->getHeader('Content-Length'))->toBe(['40']);
});
10 changes: 10 additions & 0 deletions tests/Feature/Protocols/Pusher/Reverb/EventsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,13 @@
it('fails when app cannot be found', function () {
await($this->signedPostRequest('events', appId: 'invalid-app-id'));
})->throws(ResponseException::class, exceptionCode: 404);

it('can send the content-length header', function () {
$response = await($this->signedPostRequest('events', [
'name' => 'NewEvent',
'channel' => 'test-channel',
'data' => json_encode(['some' => 'data']),
]));

expect($response->getHeader('Content-Length'))->toBe(['2']);
});

0 comments on commit 11cbaa8

Please sign in to comment.