diff --git a/src/Rest/Channel.php b/src/Rest/Channel.php index 509697a..df9c21d 100644 --- a/src/Rest/Channel.php +++ b/src/Rest/Channel.php @@ -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 diff --git a/tests/Rest/ChannelTest.php b/tests/Rest/ChannelTest.php index 457151b..ff9f4da 100644 --- a/tests/Rest/ChannelTest.php +++ b/tests/Rest/ChannelTest.php @@ -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' => [ diff --git a/tests/Rest/HttpHelperTestCase.php b/tests/Rest/HttpHelperTestCase.php index 272fa42..eff051a 100644 --- a/tests/Rest/HttpHelperTestCase.php +++ b/tests/Rest/HttpHelperTestCase.php @@ -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; }