diff --git a/Tests/Package/Activity/EventsTest.php b/Tests/Package/Activity/EventsTest.php index fc5ee51a..f71207bd 100644 --- a/Tests/Package/Activity/EventsTest.php +++ b/Tests/Package/Activity/EventsTest.php @@ -5,7 +5,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Github\Tests; +namespace Joomla\Github\Tests\Package\Activity; use Joomla\Github\Package\Activity\Events; use Joomla\Github\Tests\Stub\GitHubTestCase; @@ -62,8 +62,7 @@ public function testGetPublic() ->with('/events') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -85,8 +84,7 @@ public function testGetRepository() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -108,8 +106,7 @@ public function testGetIssue() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -131,8 +128,7 @@ public function testGetNetwork() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -154,8 +150,7 @@ public function testGetOrg() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -177,8 +172,7 @@ public function testGetUser() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -200,8 +194,7 @@ public function testGetUserPublic() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -223,8 +216,7 @@ public function testGetByUser() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -246,8 +238,7 @@ public function testGetByUserPublic() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -269,8 +260,7 @@ public function testGetUserOrg() ->with($path) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Activity/FeedsTest.php b/Tests/Package/Activity/FeedsTest.php index 687453b3..10c071eb 100644 --- a/Tests/Package/Activity/FeedsTest.php +++ b/Tests/Package/Activity/FeedsTest.php @@ -50,8 +50,7 @@ public function testGetFeeds() ->with('/feeds') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Activity/NotificationsTest.php b/Tests/Package/Activity/NotificationsTest.php index a53e9e68..14a03e8c 100644 --- a/Tests/Package/Activity/NotificationsTest.php +++ b/Tests/Package/Activity/NotificationsTest.php @@ -5,7 +5,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Github\Tests; +namespace Joomla\Github\Tests\Package\Activity; use Joomla\Github\Package\Activity\Notifications; use Joomla\Github\Tests\Stub\GitHubTestCase; @@ -54,8 +54,7 @@ public function testGetList() ->with('/notifications?all=1&participating=1&since=2005-08-17T00:00:00+00:00&before=2005-08-17T00:00:00+00:00', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -79,8 +78,7 @@ public function testGetListRepository() ->with('/repos/{owner}/{repo}/notifications?' . $args, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -111,8 +109,7 @@ public function testMarkRead() ->with('/notifications', '{"unread":true,"read":true}', [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -139,8 +136,7 @@ public function testMarkReadLastRead() ->with('/notifications', $data, [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -166,8 +162,7 @@ public function testMarkReadRepository() ->with('/repos/joomla/joomla-platform/notifications', $data, [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -194,8 +189,7 @@ public function testMarkReadRepositoryLastRead() ->with('/repos/joomla/joomla-platform/notifications', $data, [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -217,8 +211,7 @@ public function testViewThread() ->with('/notifications/threads/1', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -242,8 +235,7 @@ public function testMarkReadThread() ->with('/notifications/threads/1', '{"unread":true,"read":true}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -265,8 +257,7 @@ public function testGetThreadSubscription() ->with('/notifications/threads/1/subscription', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -288,8 +279,7 @@ public function testSetThreadSubscription() ->with('/notifications/threads/1/subscription', '{"subscribed":true,"ignored":false}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -313,8 +303,7 @@ public function testDeleteThreadSubscription() ->with('/notifications/threads/1/subscription', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Activity/StarringTest.php b/Tests/Package/Activity/StarringTest.php index 15de0abd..6f70766c 100644 --- a/Tests/Package/Activity/StarringTest.php +++ b/Tests/Package/Activity/StarringTest.php @@ -5,7 +5,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Github\Tests; +namespace Joomla\Github\Tests\Package\Activity; use Joomla\Github\Package\Activity\Starring; use Joomla\Github\Tests\Stub\GitHubTestCase; @@ -54,8 +54,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/stargazers', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -77,8 +76,7 @@ public function testGetRepositories() ->with('/user/starred?sort=created&direction=desc', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -100,8 +98,7 @@ public function testGetRepositoriesWithName() ->with('/users/{user}/starred?sort=created&direction=desc', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -157,8 +154,7 @@ public function testCheck() ->with('/user/starred/joomla/joomla-platform', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -182,8 +178,7 @@ public function testCheckFalse() ->with('/user/starred/joomla/joomla-platform', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -209,8 +204,7 @@ public function testCheckUnexpected() ->with('/user/starred/joomla/joomla-platform', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -234,8 +228,7 @@ public function testStar() ->with('/user/starred/joomla/joomla-platform', '', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -259,8 +252,7 @@ public function testUnstar() ->with('/user/starred/joomla/joomla-platform', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Activity/WatchingTest.php b/Tests/Package/Activity/WatchingTest.php index 93dec252..d7ce4b73 100644 --- a/Tests/Package/Activity/WatchingTest.php +++ b/Tests/Package/Activity/WatchingTest.php @@ -50,8 +50,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/subscribers', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -71,8 +70,7 @@ public function testGetRepositories() ->with('/user/subscriptions', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -92,8 +90,7 @@ public function testGetRepositoriesUser() ->with('/users/joomla/subscriptions', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -113,8 +110,7 @@ public function testGetSubscription() ->with('/repos/joomla/joomla-platform/subscription', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -134,8 +130,7 @@ public function testSetSubscription() ->with('/repos/joomla/joomla-platform/subscription', '{"subscribed":true,"ignored":false}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -157,8 +152,7 @@ public function testDeleteSubscription() ->with('/repos/joomla/joomla-platform/subscription', [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -239,8 +233,7 @@ public function testWatch() ->with('/user/subscriptions/joomla/joomla-platform', '', [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -262,8 +255,7 @@ public function testUnwatch() ->with('/user/subscriptions/joomla/joomla-platform', [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, diff --git a/Tests/Package/AuthorizationsTest.php b/Tests/Package/AuthorizationsTest.php index 1d690b17..f5746fc5 100644 --- a/Tests/Package/AuthorizationsTest.php +++ b/Tests/Package/AuthorizationsTest.php @@ -575,8 +575,7 @@ public function testGetAuthorizationLink() $this->response = $this->getResponseObject('https://github.com/login/oauth/authorize?client_id=12345' . '&redirect_uri=aaa&scope=bbb&state=ccc', 200); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -598,8 +597,7 @@ public function testRequestToken() ->with('https://github.com/login/oauth/access_token') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -621,8 +619,7 @@ public function testRequestTokenJson() ->with('https://github.com/login/oauth/access_token') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -644,8 +641,7 @@ public function testRequestTokenXml() ->with('https://github.com/login/oauth/access_token') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, diff --git a/Tests/Package/Data/BlobsTest.php b/Tests/Package/Data/BlobsTest.php index 04b32f27..cf528816 100644 --- a/Tests/Package/Data/BlobsTest.php +++ b/Tests/Package/Data/BlobsTest.php @@ -50,8 +50,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/git/blobs/12345', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -73,8 +72,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/git/blobs', '{"content":"Hello w\u00f6rld","encoding":"utf-8"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Data/CommitsTest.php b/Tests/Package/Data/CommitsTest.php index d9996725..401f8b25 100644 --- a/Tests/Package/Data/CommitsTest.php +++ b/Tests/Package/Data/CommitsTest.php @@ -50,8 +50,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/git/commits/12345', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -73,8 +72,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/git/commits', '{"message":"My Message","tree":"12345","parents":[]}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Data/TagsTest.php b/Tests/Package/Data/TagsTest.php index 7ecb2ea6..c6537bc1 100644 --- a/Tests/Package/Data/TagsTest.php +++ b/Tests/Package/Data/TagsTest.php @@ -50,8 +50,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/git/tags/12345', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -75,8 +74,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/git/tags', $data, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Data/TreesTest.php b/Tests/Package/Data/TreesTest.php index 41aea455..c038cb12 100644 --- a/Tests/Package/Data/TreesTest.php +++ b/Tests/Package/Data/TreesTest.php @@ -50,8 +50,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/git/trees/12345', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -71,8 +70,7 @@ public function testGetRecursively() ->with('/repos/joomla/joomla-platform/git/trees/12345?recursive=1', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -94,8 +92,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/git/trees', '{"tree":"12345","base_tree":"678"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/GitignoreTest.php b/Tests/Package/GitignoreTest.php index 0d658f16..17fc9635 100644 --- a/Tests/Package/GitignoreTest.php +++ b/Tests/Package/GitignoreTest.php @@ -62,8 +62,7 @@ public function testGetList() ->with('/gitignore/templates', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -92,8 +91,7 @@ public function testGet() ->with('/gitignore/templates/C', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -135,8 +133,7 @@ public function testGetRaw() ->with('/gitignore/templates/C', ['Accept' => 'application/vnd.github.raw+json'], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -161,8 +158,7 @@ public function testGetFailure() ->with('/gitignore/templates/X', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Issues/AssigneesTest.php b/Tests/Package/Issues/AssigneesTest.php index 6ff18987..1677276d 100644 --- a/Tests/Package/Issues/AssigneesTest.php +++ b/Tests/Package/Issues/AssigneesTest.php @@ -73,8 +73,7 @@ public function testGetList() ->with('/repos/' . $this->owner . '/' . $this->repo . '/assignees', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -185,8 +184,7 @@ public function testAdd() ->with('/repos/' . $this->owner . '/' . $this->repo . '/issues/123/assignees', json_encode(['assignees' => ['joomla']])) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -217,8 +215,7 @@ public function testRemove() ->with('/repos/' . $this->owner . '/' . $this->repo . '/issues/123/assignees', [], null, json_encode(['assignees' => ['joomla']])) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Issues/CommentsTest.php b/Tests/Package/Issues/CommentsTest.php index d0d1a8e3..053f1cd8 100644 --- a/Tests/Package/Issues/CommentsTest.php +++ b/Tests/Package/Issues/CommentsTest.php @@ -50,8 +50,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/issues/1/comments', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -71,8 +70,7 @@ public function testGetRepositoryList() ->with('/repos/joomla/joomla-platform/issues/comments?sort=created&direction=asc', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -118,8 +116,7 @@ public function testGetRepositoryListSince() ->with('/repos/joomla/joomla-platform/issues/comments?sort=created&direction=asc&since=1966-09-15T12:34:56+00:00', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -139,8 +136,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/issues/comments/1', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -160,8 +156,7 @@ public function testEdit() ->with('/repos/joomla/joomla-platform/issues/comments/1', '{"body":"Hello"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -183,8 +178,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/issues/1/comments', '{"body":"Hello"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Issues/EventsTest.php b/Tests/Package/Issues/EventsTest.php index ee9e6092..26b763da 100644 --- a/Tests/Package/Issues/EventsTest.php +++ b/Tests/Package/Issues/EventsTest.php @@ -50,8 +50,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/issues/1/events', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -71,8 +70,7 @@ public function testGetListRepository() ->with('/repos/joomla/joomla-platform/issues/1/comments', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -92,8 +90,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/issues/events/1', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Issues/LabelsTest.php b/Tests/Package/Issues/LabelsTest.php index e785fe9e..b586d072 100644 --- a/Tests/Package/Issues/LabelsTest.php +++ b/Tests/Package/Issues/LabelsTest.php @@ -50,8 +50,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/labels', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -71,8 +70,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/labels/1', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -94,8 +92,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/labels', '{"name":"foobar","color":"red"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -119,8 +116,7 @@ public function testCreateFailure() ->with('/repos/joomla/joomla-platform/labels', '{"name":"foobar","color":"red"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -140,8 +136,7 @@ public function testUpdate() ->with('/repos/joomla/joomla-platform/labels/foobar', '{"name":"boofaz","color":"red"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -163,8 +158,7 @@ public function testDelete() ->with('/repos/joomla/joomla-platform/labels/foobar', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -184,8 +178,7 @@ public function testGetListByIssue() ->with('/repos/joomla/joomla-platform/issues/1/labels', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -205,8 +198,7 @@ public function testAdd() ->with('/repos/joomla/joomla-platform/issues/1/labels', '["A","B"]', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -226,8 +218,7 @@ public function testRemoveFromIssue() ->with('/repos/joomla/joomla-platform/issues/1/labels/foobar', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -247,8 +238,7 @@ public function testReplace() ->with('/repos/joomla/joomla-platform/issues/1/labels', '["A","B"]', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -270,8 +260,7 @@ public function testRemoveAllFromIssue() ->with('/repos/joomla/joomla-platform/issues/1/labels', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -291,8 +280,7 @@ public function testGetListByMilestone() ->with('/repos/joomla/joomla-platform/milestones/1/labels', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Issues/MilestonesTest.php b/Tests/Package/Issues/MilestonesTest.php index 678d9b3e..8a071e90 100644 --- a/Tests/Package/Issues/MilestonesTest.php +++ b/Tests/Package/Issues/MilestonesTest.php @@ -58,8 +58,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/milestones', $milestone) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -109,8 +108,7 @@ public function testEdit() ->with('/repos/joomla/joomla-platform/milestones/523', json_encode($milestone)) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/MarkdownTest.php b/Tests/Package/MarkdownTest.php index afc7994e..fd2418bb 100644 --- a/Tests/Package/MarkdownTest.php +++ b/Tests/Package/MarkdownTest.php @@ -71,8 +71,7 @@ public function testRender() ->with('/markdown', $data, [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, diff --git a/Tests/Package/Pulls/CommentsTest.php b/Tests/Package/Pulls/CommentsTest.php index a686592d..1c48d82c 100644 --- a/Tests/Package/Pulls/CommentsTest.php +++ b/Tests/Package/Pulls/CommentsTest.php @@ -56,8 +56,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/pulls/1/comments', $data, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -81,8 +80,7 @@ public function testCreateReply() ->with('/repos/joomla/joomla-platform/pulls/1/comments', '{"body":"The Body","in_reply_to":456}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -106,8 +104,7 @@ public function testDelete() ->with('/repos/joomla/joomla-platform/pulls/comments/456', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -131,8 +128,7 @@ public function testEdit() ->with('/repos/joomla/joomla-platform/pulls/comments/456', '{"body":"Hello"}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -154,8 +150,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/pulls/comments/456', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -177,8 +172,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/pulls/456/comments', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -200,8 +194,7 @@ public function testGetListForRepo() ->with('/repos/{user}/{repo}/pulls/comments', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Repositories/CollaboratorsTest.php b/Tests/Package/Repositories/CollaboratorsTest.php index da6bae36..e7d69317 100644 --- a/Tests/Package/Repositories/CollaboratorsTest.php +++ b/Tests/Package/Repositories/CollaboratorsTest.php @@ -69,8 +69,7 @@ public function testGet() ->with('/repos/joomla/joomla-framework/collaborators/elkuku') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -92,8 +91,7 @@ public function testGetNegative() ->with('/repos/joomla/joomla-framework/collaborators/elkuku') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -117,8 +115,7 @@ public function testGetUnexpected() ->with('/repos/joomla/joomla-framework/collaborators/elkuku') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, diff --git a/Tests/Package/Repositories/ForksTest.php b/Tests/Package/Repositories/ForksTest.php index 22e8a1f9..504607a7 100755 --- a/Tests/Package/Repositories/ForksTest.php +++ b/Tests/Package/Repositories/ForksTest.php @@ -101,8 +101,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/forks') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Repositories/ReleasesTest.php b/Tests/Package/Repositories/ReleasesTest.php index 8c33c042..1ecf4844 100644 --- a/Tests/Package/Repositories/ReleasesTest.php +++ b/Tests/Package/Repositories/ReleasesTest.php @@ -4,7 +4,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Github\Tests; +namespace Joomla\Github\Tests\Package\Repositories; use Joomla\Github\Package\Repositories\Releases; use Joomla\Github\Tests\Stub\GitHubTestCase; @@ -50,8 +50,7 @@ public function testGet() ->with('/repos/joomla/joomla-platform/releases/12345', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -74,8 +73,7 @@ public function testCreate() ->with('/repos/joomla/joomla-platform/releases', $data, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -98,8 +96,7 @@ public function testCreateFailure() ->with('/repos/joomla/joomla-platform/releases', $data, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -123,8 +120,7 @@ public function testEdit() ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -143,7 +139,7 @@ public function testGetList() $releases = []; - foreach (json_decode($this->response->getBody()->getContents()) as $i => $release) { + foreach (json_decode((string) $this->response->getBody()) as $i => $release) { $releases[$i + 1] = $release; } @@ -152,8 +148,7 @@ public function testGetList() ->with('/repos/joomla/joomla-platform/releases', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $releases, @@ -175,8 +170,7 @@ public function testDelete() ->with('/repos/joomla/joomla-platform/releases/123') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -200,8 +194,7 @@ public function testGetLatest() ->with('/repos/joomla/joomla-platform/releases/latest', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -221,8 +214,7 @@ public function testGetByTag() ->with('/repos/joomla/joomla-platform/releases/tags/{tag}', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -242,8 +234,7 @@ public function testGetListAssets() ->with('/repos/joomla/joomla-platform/releases/123/assets', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -263,8 +254,7 @@ public function testGetAsset() ->with('/repos/joomla/joomla-platform/releases/assets/123', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -286,8 +276,7 @@ public function testEditAsset() ->with('/repos/joomla/joomla-platform/releases/assets/123', $data, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/RepositoriesTest.php b/Tests/Package/RepositoriesTest.php index 7bac64e8..30649952 100644 --- a/Tests/Package/RepositoriesTest.php +++ b/Tests/Package/RepositoriesTest.php @@ -48,8 +48,7 @@ public function testGetListOwn() ->with('/user/repos?type=all&sort=full_name&direction=asc', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -105,8 +104,7 @@ public function testGetListUser() ->with('/users/joomla/repos?type=all&sort=full_name&direction=asc', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -162,8 +160,7 @@ public function testGetListOrg() ->with('/orgs/joomla/repos?type=all', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -183,8 +180,7 @@ public function testGetList() ->with('/repositories', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -212,8 +208,7 @@ public function testCreate() ) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -241,8 +236,7 @@ public function testCreateWithOrg() ) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -262,8 +256,7 @@ public function testGet() ->with('/repos/joomla/joomla-cms', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -300,8 +293,7 @@ public function testEdit() ) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -321,8 +313,7 @@ public function testGetListContributors() ->with('/repos/joomla/joomla-cms/contributors', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -342,8 +333,7 @@ public function testGetListLanguages() ->with('/repos/joomla/joomla-cms/languages', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -363,8 +353,7 @@ public function testGetListTeams() ->with('/repos/joomla/joomla-cms/teams', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -384,8 +373,7 @@ public function testGetListTags() ->with('/repos/joomla/joomla-cms/tags', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -405,8 +393,7 @@ public function testDelete() ->with('/repos/joomla/joomla-cms', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/Users/FollowersTest.php b/Tests/Package/Users/FollowersTest.php index 569dae30..2ec8bb15 100644 --- a/Tests/Package/Users/FollowersTest.php +++ b/Tests/Package/Users/FollowersTest.php @@ -136,8 +136,7 @@ public function testCheck() ->with('/user/following/joomla') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -163,8 +162,7 @@ public function testCheckNo() ->with('/user/following/joomla') ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -190,8 +188,7 @@ public function testCheckUnexpected() ->with('/user/following/joomla') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -215,8 +212,7 @@ public function testFollow() ->with('/user/following/joomla') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -240,8 +236,7 @@ public function testUnfollow() ->with('/user/following/joomla') ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, diff --git a/Tests/Package/UsersTest.php b/Tests/Package/UsersTest.php index 4b631230..1d8f965f 100755 --- a/Tests/Package/UsersTest.php +++ b/Tests/Package/UsersTest.php @@ -4,7 +4,7 @@ * @license GNU General Public License version 2 or later; see LICENSE */ -namespace Joomla\Github\Tests; +namespace Joomla\Github\Tests\Package; use Joomla\Github\Package\Users; use Joomla\Github\Tests\Stub\GitHubTestCase; @@ -72,8 +72,7 @@ public function testGet() ->with('/users/joomla', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -97,8 +96,7 @@ public function testGetFailure() ->with('/users/nonexistentuser', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -152,8 +150,7 @@ public function testGetAuthenticatedUser() ->with('/user', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -179,8 +176,7 @@ public function testGetAuthenticatedUserFailure() ->with('/user', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -220,8 +216,7 @@ public function testGetList() ->with('/users', [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -294,8 +289,7 @@ public function testEdit() ->with('/user', $input, [], 0) ->willReturn($this->response); - $response = json_decode($this->response->getBody()->getContents()); - $this->response->getBody()->rewind(); + $response = json_decode((string) $this->response->getBody()); $this->assertEquals( $response, @@ -342,7 +336,7 @@ public function testEditFailure() // $this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio); $this->assertEquals( - json_decode($this->response->getBody()->getContents()), + json_decode((string) $this->response->getBody()), $this->object->edit($name, $email, $blog, $company, $location, $hireable, $bio) ); } diff --git a/Tests/Package/ZenTest.php b/Tests/Package/ZenTest.php index fdd50ed0..f2e80063 100644 --- a/Tests/Package/ZenTest.php +++ b/Tests/Package/ZenTest.php @@ -51,8 +51,7 @@ public function testGet() ->with('/zen', [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, @@ -76,8 +75,7 @@ public function testGetFailure() ->with('/zen', [], 0) ->willReturn($this->response); - $response = $this->response->getBody()->getContents(); - $this->response->getBody()->rewind(); + $response = (string) $this->response->getBody(); $this->assertEquals( $response, diff --git a/src/AbstractGithubObject.php b/src/AbstractGithubObject.php index 80fa942a..70fdbaa6 100644 --- a/src/AbstractGithubObject.php +++ b/src/AbstractGithubObject.php @@ -163,12 +163,12 @@ protected function processResponse(Response $response, $expectedCode = 200) // Validate the response code. if ($response->getStatusCode() != $expectedCode) { // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; throw new UnexpectedResponseException($response, $message, $response->getStatusCode()); } - return json_decode($response->getBody()->getContents()); + return json_decode((string) $response->getBody()); } } diff --git a/src/Package/Authorization.php b/src/Package/Authorization.php index 10b881f2..bf3317e4 100644 --- a/src/Package/Authorization.php +++ b/src/Package/Authorization.php @@ -249,12 +249,12 @@ public function getRateLimit() } // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); throw new UnexpectedResponseException($response, $error->message, $response->getStatusCode()); } - return json_decode($response->getBody()->getContents()); + return json_decode((string) $response->getBody()); } /** diff --git a/src/Package/Gists.php b/src/Package/Gists.php index 2caede30..88fd5d64 100644 --- a/src/Package/Gists.php +++ b/src/Package/Gists.php @@ -342,7 +342,7 @@ public function isStarred($gistId) } // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; throw new UnexpectedResponseException($response, $message, $response->getStatusCode()); diff --git a/src/Package/Gitignore.php b/src/Package/Gitignore.php index 1bb2674d..6105a290 100644 --- a/src/Package/Gitignore.php +++ b/src/Package/Gitignore.php @@ -70,12 +70,12 @@ public function get($name, $raw = false) // Validate the response code. if ($response->getStatusCode() != 200) { // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; throw new UnexpectedResponseException($response, $message, $response->getStatusCode()); } - return ($raw) ? $response->getBody()->getContents() : json_decode($response->getBody()->getContents()); + return ($raw) ? (string) $response->getBody() : json_decode((string) $response->getBody()); } } diff --git a/src/Package/Markdown.php b/src/Package/Markdown.php index 19ffd454..aa379d34 100644 --- a/src/Package/Markdown.php +++ b/src/Package/Markdown.php @@ -66,12 +66,12 @@ public function render($text, $mode = 'gfm', $context = null) // Validate the response code. if ($response->getStatusCode() != 200) { // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; throw new UnexpectedResponseException($response, $message, $response->getStatusCode()); } - return $response->getBody()->getContents(); + return (string) $response->getBody(); } } diff --git a/src/Package/Orgs/Members.php b/src/Package/Orgs/Members.php index ac2892ae..7d96e005 100644 --- a/src/Package/Orgs/Members.php +++ b/src/Package/Orgs/Members.php @@ -50,7 +50,7 @@ public function getList($org) return false; case 200: - return json_decode($response->getBody()->getContents()); + return json_decode((string) $response->getBody()); default: throw new \UnexpectedValueException('Unexpected response code: ' . $response->getStatusCode()); diff --git a/src/Package/Orgs/Teams.php b/src/Package/Orgs/Teams.php index ddf91cc5..7aaa82eb 100644 --- a/src/Package/Orgs/Teams.php +++ b/src/Package/Orgs/Teams.php @@ -297,7 +297,7 @@ public function getTeamMembership($id, $user) switch ($response->getStatusCode()) { case 200: // Response if user is an active member or pending membership - $body = json_decode($response->getBody()->getContents()); + $body = json_decode((string) $response->getBody()); return $body->state; diff --git a/src/Package/Pulls.php b/src/Package/Pulls.php index 599b23e9..986a308a 100644 --- a/src/Package/Pulls.php +++ b/src/Package/Pulls.php @@ -271,7 +271,7 @@ public function isMerged($user, $repo, $pullId) } // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; throw new UnexpectedResponseException($response, $message, $response->getStatusCode()); diff --git a/src/Package/Repositories/Commits.php b/src/Package/Repositories/Commits.php index 299b6f7a..104c0428 100644 --- a/src/Package/Repositories/Commits.php +++ b/src/Package/Repositories/Commits.php @@ -117,13 +117,13 @@ public function getSha($user, $repo, $ref) // Validate the response code. if ($response->getStatusCode() != 200) { // Decode the error response and throw an exception. - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = isset($error->message) ? $error->message : 'Invalid response received from GitHub.'; throw new UnexpectedResponseException($response, $message, $response->getStatusCode()); } - return $response->getBody()->getContents(); + return (string) $response->getBody(); } /** diff --git a/src/Package/Repositories/Deployments.php b/src/Package/Repositories/Deployments.php index fc672ee3..445583c7 100644 --- a/src/Package/Repositories/Deployments.php +++ b/src/Package/Repositories/Deployments.php @@ -129,11 +129,11 @@ public function create( switch ($response->getStatusCode()) { case 201: // The deployment was successful - return json_decode($response->getBody()->getContents()); + return json_decode((string) $response->getBody()); case 409: // There was a merge conflict or a status check failed. - $body = json_decode($response->getBody()->getContents()); + $body = json_decode((string) $response->getBody()); $message = isset($body->message) ? $body->message : 'Invalid response received from GitHub.'; throw new \RuntimeException($message, $response->getStatusCode()); diff --git a/src/Package/Repositories/Merging.php b/src/Package/Repositories/Merging.php index 81c77833..e12d746d 100644 --- a/src/Package/Repositories/Merging.php +++ b/src/Package/Repositories/Merging.php @@ -55,7 +55,7 @@ public function perform($owner, $repo, $base, $head, $commitMessage = '') switch ($response->getStatusCode()) { case '201': // Success - return json_decode($response->getBody()->getContents()); + return json_decode((string) $response->getBody()); case '204': // No-op response (base already contains the head, nothing to merge) @@ -63,7 +63,7 @@ public function perform($owner, $repo, $base, $head, $commitMessage = '') case '404': // Missing base or Missing head response - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = (isset($error->message)) ? $error->message : 'Missing base or head: ' . $response->getStatusCode(); @@ -71,7 +71,7 @@ public function perform($owner, $repo, $base, $head, $commitMessage = '') case '409': // Merge conflict response - $error = json_decode($response->getBody()->getContents()); + $error = json_decode((string) $response->getBody()); $message = (isset($error->message)) ? $error->message : 'Merge conflict ' . $response->getStatusCode(); diff --git a/src/Package/Zen.php b/src/Package/Zen.php index 2d477c1a..066887e6 100644 --- a/src/Package/Zen.php +++ b/src/Package/Zen.php @@ -35,6 +35,6 @@ public function get() throw new \RuntimeException('Can\'t get a Zen'); } - return $response->getBody()->getContents(); + return (string) $response->getBody(); } }