Skip to content
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
2 changes: 1 addition & 1 deletion src/Rest/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function getReactions(
return $this->mapArrayPromise(
$this->http->get(
Endpoint::bind(
Endpoint::CHANNEL_MESSAGES,
Endpoint::MESSAGE_REACTION_EMOJI,
$channelId,
$messageId,
(string) $emoji
Expand Down
1 change: 1 addition & 0 deletions tests/Rest/ChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ public static function httpBindingsProvider(): array
'validationOptions' => [
'returnType' => User::class,
'array' => true,
'url' => 'channels/::channel id::/messages/::message id::/reactions/%3A%3Aid%3A%3A',
]
],
'Delete all reactions' => [
Expand Down
26 changes: 22 additions & 4 deletions tests/Rest/HttpHelperTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,34 @@ abstract public static function httpBindingsProvider(): array;
#[DataProvider('httpBindingsProvider')]
public function testFunctions(string $method, array $args, array $mockOptions, array $validationOptions): void
{
$this->http->shouldReceive($mockOptions['method'])->andReturns(
new Promise(static function ($resolve) use ($mockOptions) {
$resolve($mockOptions['return']);
$requestedUrl = null;

$this->http->shouldReceive($mockOptions['method'])
->withArgs(static function ($url, ...$rest) use (&$requestedUrl) {
$requestedUrl = (string) $url;

return true;
})
)->once();
->andReturns(
new Promise(static function ($resolve) use ($mockOptions) {
$resolve($mockOptions['return']);
})
)->once();

$response = await(call_user_func_array([$this->httpItem, $method], $args));

$this->http->shouldHaveReceived($mockOptions['method']);

/*
* Optional, and worth filling in: nothing here checked which endpoint a
* method actually called, so a method binding the wrong Endpoint
* constant passed its test while never once reaching the route it was
* named after.
*/
if (isset($validationOptions['url'])) {
$this->assertSame($validationOptions['url'], $requestedUrl);
}

if (!isset($validationOptions['returnType'])) {
return;
}
Expand Down