Skip to content

Commit 47dc6b9

Browse files
committed
Change access to body of Response object
1 parent 417aa8e commit 47dc6b9

37 files changed

+120
-250
lines changed

Tests/Package/Activity/EventsTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function testGetPublic()
6262
->with('/events')
6363
->willReturn($this->response);
6464

65-
$response = json_decode($this->response->getBody()->getContents());
66-
$this->response->getBody()->rewind();
65+
$response = json_decode((string) $this->response->getBody());
6766

6867
$this->assertEquals(
6968
$response,
@@ -85,8 +84,7 @@ public function testGetRepository()
8584
->with($path)
8685
->willReturn($this->response);
8786

88-
$response = json_decode($this->response->getBody()->getContents());
89-
$this->response->getBody()->rewind();
87+
$response = json_decode((string) $this->response->getBody());
9088

9189
$this->assertEquals(
9290
$response,
@@ -109,7 +107,6 @@ public function testGetIssue()
109107
->willReturn($this->response);
110108

111109
$response = json_decode($this->response->getBody()->getContents());
112-
$this->response->getBody()->rewind();
113110

114111
$this->assertEquals(
115112
$response,
@@ -132,7 +129,6 @@ public function testGetNetwork()
132129
->willReturn($this->response);
133130

134131
$response = json_decode($this->response->getBody()->getContents());
135-
$this->response->getBody()->rewind();
136132

137133
$this->assertEquals(
138134
$response,
@@ -155,7 +151,6 @@ public function testGetOrg()
155151
->willReturn($this->response);
156152

157153
$response = json_decode($this->response->getBody()->getContents());
158-
$this->response->getBody()->rewind();
159154

160155
$this->assertEquals(
161156
$response,
@@ -178,7 +173,6 @@ public function testGetUser()
178173
->willReturn($this->response);
179174

180175
$response = json_decode($this->response->getBody()->getContents());
181-
$this->response->getBody()->rewind();
182176

183177
$this->assertEquals(
184178
$response,
@@ -201,7 +195,6 @@ public function testGetUserPublic()
201195
->willReturn($this->response);
202196

203197
$response = json_decode($this->response->getBody()->getContents());
204-
$this->response->getBody()->rewind();
205198

206199
$this->assertEquals(
207200
$response,
@@ -224,7 +217,6 @@ public function testGetByUser()
224217
->willReturn($this->response);
225218

226219
$response = json_decode($this->response->getBody()->getContents());
227-
$this->response->getBody()->rewind();
228220

229221
$this->assertEquals(
230222
$response,
@@ -247,7 +239,6 @@ public function testGetByUserPublic()
247239
->willReturn($this->response);
248240

249241
$response = json_decode($this->response->getBody()->getContents());
250-
$this->response->getBody()->rewind();
251242

252243
$this->assertEquals(
253244
$response,
@@ -270,7 +261,6 @@ public function testGetUserOrg()
270261
->willReturn($this->response);
271262

272263
$response = json_decode($this->response->getBody()->getContents());
273-
$this->response->getBody()->rewind();
274264

275265
$this->assertEquals(
276266
$response,

Tests/Package/Activity/FeedsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public function testGetFeeds()
5050
->with('/feeds')
5151
->willReturn($this->response);
5252

53-
$response = json_decode($this->response->getBody()->getContents());
54-
$this->response->getBody()->rewind();
53+
$response = json_decode((string) $this->response->getBody());
5554

5655
$this->assertEquals(
5756
$response,

Tests/Package/Activity/NotificationsTest.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public function testGetList()
5454
->with('/notifications?all=1&participating=1&since=2005-08-17T00:00:00+00:00&before=2005-08-17T00:00:00+00:00', [], 0)
5555
->willReturn($this->response);
5656

57-
$response = json_decode($this->response->getBody()->getContents());
58-
$this->response->getBody()->rewind();
57+
$response = json_decode((string) $this->response->getBody());
5958

6059
$this->assertEquals(
6160
$response,
@@ -79,8 +78,7 @@ public function testGetListRepository()
7978
->with('/repos/{owner}/{repo}/notifications?' . $args, [], 0)
8079
->willReturn($this->response);
8180

82-
$response = json_decode($this->response->getBody()->getContents());
83-
$this->response->getBody()->rewind();
81+
$response = json_decode((string) $this->response->getBody());
8482

8583
$this->assertEquals(
8684
$response,
@@ -111,8 +109,7 @@ public function testMarkRead()
111109
->with('/notifications', '{"unread":true,"read":true}', [], 0)
112110
->willReturn($this->response);
113111

114-
$response = $this->response->getBody()->getContents();
115-
$this->response->getBody()->rewind();
112+
$response = (string) $this->response->getBody();
116113

117114
$this->assertEquals(
118115
$response,
@@ -139,8 +136,7 @@ public function testMarkReadLastRead()
139136
->with('/notifications', $data, [], 0)
140137
->willReturn($this->response);
141138

142-
$response = $this->response->getBody()->getContents();
143-
$this->response->getBody()->rewind();
139+
$response = (string) $this->response->getBody();
144140

145141
$this->assertEquals(
146142
$response,
@@ -166,8 +162,7 @@ public function testMarkReadRepository()
166162
->with('/repos/joomla/joomla-platform/notifications', $data, [], 0)
167163
->willReturn($this->response);
168164

169-
$response = $this->response->getBody()->getContents();
170-
$this->response->getBody()->rewind();
165+
$response = (string) $this->response->getBody();
171166

172167
$this->assertEquals(
173168
$response,
@@ -195,7 +190,6 @@ public function testMarkReadRepositoryLastRead()
195190
->willReturn($this->response);
196191

197192
$response = $this->response->getBody()->getContents();
198-
$this->response->getBody()->rewind();
199193

200194
$this->assertEquals(
201195
$response,
@@ -218,7 +212,6 @@ public function testViewThread()
218212
->willReturn($this->response);
219213

220214
$response = json_decode($this->response->getBody()->getContents());
221-
$this->response->getBody()->rewind();
222215

223216
$this->assertEquals(
224217
$response,
@@ -243,7 +236,6 @@ public function testMarkReadThread()
243236
->willReturn($this->response);
244237

245238
$response = json_decode($this->response->getBody()->getContents());
246-
$this->response->getBody()->rewind();
247239

248240
$this->assertEquals(
249241
$response,
@@ -266,7 +258,6 @@ public function testGetThreadSubscription()
266258
->willReturn($this->response);
267259

268260
$response = json_decode($this->response->getBody()->getContents());
269-
$this->response->getBody()->rewind();
270261

271262
$this->assertEquals(
272263
$response,
@@ -289,7 +280,6 @@ public function testSetThreadSubscription()
289280
->willReturn($this->response);
290281

291282
$response = json_decode($this->response->getBody()->getContents());
292-
$this->response->getBody()->rewind();
293283

294284
$this->assertEquals(
295285
$response,
@@ -314,7 +304,6 @@ public function testDeleteThreadSubscription()
314304
->willReturn($this->response);
315305

316306
$response = json_decode($this->response->getBody()->getContents());
317-
$this->response->getBody()->rewind();
318307

319308
$this->assertEquals(
320309
$response,

Tests/Package/Activity/StarringTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public function testGetList()
5454
->with('/repos/joomla/joomla-platform/stargazers', [], 0)
5555
->willReturn($this->response);
5656

57-
$response = json_decode($this->response->getBody()->getContents());
58-
$this->response->getBody()->rewind();
57+
$response = json_decode((string) $this->response->getBody());
5958

6059
$this->assertEquals(
6160
$response,
@@ -77,8 +76,7 @@ public function testGetRepositories()
7776
->with('/user/starred?sort=created&direction=desc', [], 0)
7877
->willReturn($this->response);
7978

80-
$response = json_decode($this->response->getBody()->getContents());
81-
$this->response->getBody()->rewind();
79+
$response = json_decode((string) $this->response->getBody());
8280

8381
$this->assertEquals(
8482
$response,
@@ -100,8 +98,7 @@ public function testGetRepositoriesWithName()
10098
->with('/users/{user}/starred?sort=created&direction=desc', [], 0)
10199
->willReturn($this->response);
102100

103-
$response = json_decode($this->response->getBody()->getContents());
104-
$this->response->getBody()->rewind();
101+
$response = json_decode((string) $this->response->getBody());
105102

106103
$this->assertEquals(
107104
$response,
@@ -157,8 +154,7 @@ public function testCheck()
157154
->with('/user/starred/joomla/joomla-platform', [], 0)
158155
->willReturn($this->response);
159156

160-
$response = json_decode($this->response->getBody()->getContents());
161-
$this->response->getBody()->rewind();
157+
$response = json_decode((string) $this->response->getBody());
162158

163159
$this->assertEquals(
164160
$response,
@@ -183,7 +179,6 @@ public function testCheckFalse()
183179
->willReturn($this->response);
184180

185181
$response = json_decode($this->response->getBody()->getContents());
186-
$this->response->getBody()->rewind();
187182

188183
$this->assertEquals(
189184
$response,
@@ -210,7 +205,6 @@ public function testCheckUnexpected()
210205
->willReturn($this->response);
211206

212207
$response = json_decode($this->response->getBody()->getContents());
213-
$this->response->getBody()->rewind();
214208

215209
$this->assertEquals(
216210
$response,
@@ -235,7 +229,6 @@ public function testStar()
235229
->willReturn($this->response);
236230

237231
$response = json_decode($this->response->getBody()->getContents());
238-
$this->response->getBody()->rewind();
239232

240233
$this->assertEquals(
241234
$response,
@@ -260,7 +253,6 @@ public function testUnstar()
260253
->willReturn($this->response);
261254

262255
$response = json_decode($this->response->getBody()->getContents());
263-
$this->response->getBody()->rewind();
264256

265257
$this->assertEquals(
266258
$response,

Tests/Package/Activity/WatchingTest.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public function testGetList()
5050
->with('/repos/joomla/joomla-platform/subscribers', [], 0)
5151
->willReturn($this->response);
5252

53-
$response = json_decode($this->response->getBody()->getContents());
54-
$this->response->getBody()->rewind();
53+
$response = json_decode((string) $this->response->getBody());
5554

5655
$this->assertEquals(
5756
$response,
@@ -71,8 +70,7 @@ public function testGetRepositories()
7170
->with('/user/subscriptions', [], 0)
7271
->willReturn($this->response);
7372

74-
$response = json_decode($this->response->getBody()->getContents());
75-
$this->response->getBody()->rewind();
73+
$response = json_decode((string) $this->response->getBody());
7674

7775
$this->assertEquals(
7876
$response,
@@ -92,8 +90,7 @@ public function testGetRepositoriesUser()
9290
->with('/users/joomla/subscriptions', [], 0)
9391
->willReturn($this->response);
9492

95-
$response = json_decode($this->response->getBody()->getContents());
96-
$this->response->getBody()->rewind();
93+
$response = json_decode((string) $this->response->getBody());
9794

9895
$this->assertEquals(
9996
$response,
@@ -113,8 +110,7 @@ public function testGetSubscription()
113110
->with('/repos/joomla/joomla-platform/subscription', [], 0)
114111
->willReturn($this->response);
115112

116-
$response = json_decode($this->response->getBody()->getContents());
117-
$this->response->getBody()->rewind();
113+
$response = json_decode((string) $this->response->getBody());
118114

119115
$this->assertEquals(
120116
$response,
@@ -134,8 +130,7 @@ public function testSetSubscription()
134130
->with('/repos/joomla/joomla-platform/subscription', '{"subscribed":true,"ignored":false}', [], 0)
135131
->willReturn($this->response);
136132

137-
$response = json_decode($this->response->getBody()->getContents());
138-
$this->response->getBody()->rewind();
133+
$response = json_decode((string) $this->response->getBody());
139134

140135
$this->assertEquals(
141136
$response,
@@ -157,8 +152,7 @@ public function testDeleteSubscription()
157152
->with('/repos/joomla/joomla-platform/subscription', [], 0)
158153
->willReturn($this->response);
159154

160-
$response = $this->response->getBody()->getContents();
161-
$this->response->getBody()->rewind();
155+
$response = (string) $this->response->getBody();
162156

163157
$this->assertEquals(
164158
$response,
@@ -239,8 +233,7 @@ public function testWatch()
239233
->with('/user/subscriptions/joomla/joomla-platform', '', [], 0)
240234
->willReturn($this->response);
241235

242-
$response = $this->response->getBody()->getContents();
243-
$this->response->getBody()->rewind();
236+
$response = (string) $this->response->getBody();
244237

245238
$this->assertEquals(
246239
$response,
@@ -262,8 +255,7 @@ public function testUnwatch()
262255
->with('/user/subscriptions/joomla/joomla-platform', [], 0)
263256
->willReturn($this->response);
264257

265-
$response = $this->response->getBody()->getContents();
266-
$this->response->getBody()->rewind();
258+
$response = (string) $this->response->getBody();
267259

268260
$this->assertEquals(
269261
$response,

Tests/Package/AuthorizationsTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,7 @@ public function testGetAuthorizationLink()
575575
$this->response = $this->getResponseObject('https://github.com/login/oauth/authorize?client_id=12345'
576576
. '&redirect_uri=aaa&scope=bbb&state=ccc', 200);
577577

578-
$response = $this->response->getBody()->getContents();
579-
$this->response->getBody()->rewind();
578+
$response = (string) $this->response->getBody();
580579

581580
$this->assertEquals(
582581
$response,
@@ -598,8 +597,7 @@ public function testRequestToken()
598597
->with('https://github.com/login/oauth/access_token')
599598
->willReturn($this->response);
600599

601-
$response = $this->response->getBody()->getContents();
602-
$this->response->getBody()->rewind();
600+
$response = (string) $this->response->getBody();
603601

604602
$this->assertEquals(
605603
$response,
@@ -621,8 +619,7 @@ public function testRequestTokenJson()
621619
->with('https://github.com/login/oauth/access_token')
622620
->willReturn($this->response);
623621

624-
$response = $this->response->getBody()->getContents();
625-
$this->response->getBody()->rewind();
622+
$response = (string) $this->response->getBody();
626623

627624
$this->assertEquals(
628625
$response,
@@ -644,8 +641,7 @@ public function testRequestTokenXml()
644641
->with('https://github.com/login/oauth/access_token')
645642
->willReturn($this->response);
646643

647-
$response = $this->response->getBody()->getContents();
648-
$this->response->getBody()->rewind();
644+
$response = (string) $this->response->getBody();
649645

650646
$this->assertEquals(
651647
$response,

0 commit comments

Comments
 (0)