diff --git a/lib/Github/ResultPager.php b/lib/Github/ResultPager.php index a1d94785ca6..f23b6c6f418 100644 --- a/lib/Github/ResultPager.php +++ b/lib/Github/ResultPager.php @@ -86,7 +86,7 @@ public function fetch(AbstractApi $api, string $method, array $parameters = []): $api = $closure($api); $result = $api->$method(...$parameters); - if ($result === '' && $this->client->getLastResponse()->getStatusCode() === 204) { + if ($result === '') { $result = []; } diff --git a/test/Github/Tests/ResultPagerTest.php b/test/Github/Tests/ResultPagerTest.php index 3df610ee250..b898528483b 100644 --- a/test/Github/Tests/ResultPagerTest.php +++ b/test/Github/Tests/ResultPagerTest.php @@ -7,6 +7,7 @@ use Github\Api\Repo; use Github\Api\Repository\Statuses; use Github\Api\Search; +use Github\Api\User; use Github\Client; use Github\ResultPager; use Github\Tests\Mock\PaginatedResponse; @@ -176,6 +177,29 @@ public function testFetch() $this->assertEquals($result, $paginator->fetch($api, $method, $parameters)); } + public function testEmptyFetch() + { + $parameters = ['username']; + $api = $this->getMockBuilder(User::class) + ->disableOriginalConstructor() + ->onlyMethods(['events']) + ->getMock(); + $api->expects($this->once()) + ->method('events') + ->with(...$parameters) + ->willReturn(''); + + $paginator = $this->getMockBuilder(ResultPager::class) + ->disableOriginalConstructor() + ->onlyMethods(['postFetch']) + ->getMock(); + + $paginator->expects($this->once()) + ->method('postFetch'); + + $this->assertEquals([], $paginator->fetch($api, 'events', $parameters)); + } + public function testFetchAllPreserveKeys() { $content = [