Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 0a0c124

Browse files
committed
Add test
1 parent a0ea061 commit 0a0c124

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/HttpApi/FetchChannelsTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,35 @@ public function it_returns_the_channel_information()
8080
],
8181
], json_decode($response->getContent(), true));
8282
}
83+
84+
/** @test */
85+
public function it_returns_empty_object_for_no_channels_found()
86+
{
87+
$connection = new Connection();
88+
89+
$auth_key = 'TestKey';
90+
$auth_timestamp = time();
91+
$auth_version = '1.0';
92+
93+
$queryParameters = http_build_query(compact('auth_key', 'auth_timestamp', 'auth_version'));
94+
95+
$signature =
96+
"GET\n/apps/1234/channels\n".
97+
"auth_key={$auth_key}".
98+
"&auth_timestamp={$auth_timestamp}".
99+
"&auth_version={$auth_version}";
100+
101+
$auth_signature = hash_hmac('sha256', $signature, 'TestSecret');
102+
103+
$request = new Request('GET', "/apps/1234/channels?appId=1234&auth_signature={$auth_signature}&{$queryParameters}");
104+
105+
$controller = app(FetchChannelsController::class);
106+
107+
$controller->onOpen($connection, $request);
108+
109+
/** @var JsonResponse $response */
110+
$response = array_pop($connection->sentRawData);
111+
112+
$this->assertSame('{"channels":{}}', $response->getContent());
113+
}
83114
}

0 commit comments

Comments
 (0)