Skip to content

Commit 7c9f049

Browse files
authored
Merge pull request #42 from laminas/renovate/psr-http-message-2.x
Update dependency psr/http-message to v2
2 parents eb3a7d7 + 6023582 commit 7c9f049

File tree

8 files changed

+57
-24
lines changed

8 files changed

+57
-24
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"psr/container": "^1.1.2 || ^2.0.2",
4646
"psr/event-dispatcher": "^1.0",
4747
"psr/http-factory": "^1.0.2",
48-
"psr/http-message": "^1.1.0",
48+
"psr/http-message": "^2.0.0",
4949
"psr/http-server-handler": "^1.0.2",
5050
"psr/http-server-middleware": "^1.0.2",
5151
"psr/log": "^1.1 || ^2.0 || ^3.0"

composer.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/GitHub/Listener/DocsBuildActionListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use App\Slack\Domain\SlashResponseMessage;
1111
use App\Slack\Response\SlackResponse;
1212
use App\Slack\SlackClientInterface;
13+
use AppTest\Psr7Helper;
1314
use PHPUnit\Framework\TestCase;
1415
use Prophecy\Argument;
1516
use Prophecy\PhpUnit\ProphecyTrait;
@@ -81,7 +82,7 @@ public function testLogsErrorAndReportsViaSlackIfGitHubRequestFails(int $httpSta
8182

8283
$response = $this->prophesize(ResponseInterface::class);
8384
$response->getStatusCode()->willReturn($httpStatus)->shouldBeCalled();
84-
$response->getBody()->willReturn('error message from github')->shouldBeCalled();
85+
$response->getBody()->willReturn(Psr7Helper::stream('error message from github'))->shouldBeCalled();
8586

8687
$this->githubClient->send($request->reveal())->will([$response, 'reveal'])->shouldBeCalled();
8788

test/GitHub/Listener/GitHubReleaseWebsiteUpdateListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\GitHub\Event\GitHubRelease;
88
use App\GitHub\Listener\GitHubReleaseWebsiteUpdateListener;
99
use App\HttpClientInterface;
10+
use AppTest\Psr7Helper;
1011
use PHPUnit\Framework\TestCase;
1112
use Prophecy\Argument;
1213
use Prophecy\PhpUnit\ProphecyTrait;
@@ -128,7 +129,7 @@ public function testLogsErrorUpdatingWebsite(): void
128129

129130
$response = $this->prophesize(ResponseInterface::class);
130131
$response->getStatusCode()->willReturn(400);
131-
$response->getBody()->willReturn('');
132+
$response->getBody()->willReturn(Psr7Helper::stream(''));
132133

133134
$this->httpClient->send($request->reveal())->will([$response, 'reveal'])->shouldBeCalled();
134135

test/GitHub/Listener/GitHubStatusListenerTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use App\Slack\Domain\WebAPIMessage;
1414
use App\Slack\Response\SlackResponseInterface;
1515
use App\Slack\SlackClientInterface;
16+
use AppTest\Psr7Helper;
1617
use PHPUnit\Framework\TestCase;
1718
use Prophecy\Argument;
1819
use Prophecy\PhpUnit\ProphecyTrait;
@@ -103,7 +104,7 @@ public function testLogsErrorAndNotifiesSlackWithGenericMessageForPullRequestWhe
103104
$ghRequest = $this->prophesize(RequestInterface::class);
104105
$ghResponse = $this->prophesize(ResponseInterface::class);
105106
$ghResponse->getStatusCode()->willReturn(400)->shouldBeCalled();
106-
$ghResponse->getBody()->willReturn('')->shouldBeCalled();
107+
$ghResponse->getBody()->willReturn(Psr7Helper::stream(''))->shouldBeCalled();
107108

108109
$this->githubClient
109110
->createRequest(
@@ -246,7 +247,7 @@ public function testNotifesSlackWithPullRequestBuildStatusWhenSearchHasAtLeastOn
246247

247248
$ghRequest = $this->prophesize(RequestInterface::class);
248249

249-
$ghResponsePayload = json_encode([
250+
$ghResponsePayload = Psr7Helper::stream(json_encode([
250251
'incomplete_results' => false,
251252
'items' => [
252253
[
@@ -255,7 +256,7 @@ public function testNotifesSlackWithPullRequestBuildStatusWhenSearchHasAtLeastOn
255256
'html_url' => 'pull-request-url',
256257
],
257258
],
258-
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
259+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
259260

260261
$ghResponse = $this->prophesize(ResponseInterface::class);
261262
$ghResponse->getStatusCode()->willReturn(200)->shouldBeCalled();

test/GitHub/Listener/RegisterWebhookListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use App\Slack\Response\SlackResponseInterface;
1212
use App\Slack\SlackClientInterface;
1313
use App\UrlHelper;
14+
use AppTest\Psr7Helper;
1415
use PHPUnit\Framework\TestCase;
1516
use Prophecy\Argument;
1617
use Prophecy\PhpUnit\ProphecyTrait;
@@ -153,7 +154,7 @@ public function testLogsErrorAndNotifiesSlackWhenWebhookRegistrationFails(): voi
153154

154155
$response = $this->prophesize(ResponseInterface::class);
155156
$response->getStatusCode()->willReturn(400)->shouldBeCalled();
156-
$response->getBody()->willReturn('');
157+
$response->getBody()->willReturn(Psr7Helper::stream(''));
157158

158159
$this->github
159160
->createRequest(

test/Psr7Helper.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AppTest;
6+
7+
use Laminas\Diactoros\StreamFactory;
8+
use Psr\Http\Message\StreamFactoryInterface;
9+
use Psr\Http\Message\StreamInterface;
10+
11+
class Psr7Helper
12+
{
13+
public static ?StreamFactoryInterface $streamFactory = null;
14+
15+
public static function streamFactory(): StreamFactoryInterface
16+
{
17+
if (self::$streamFactory === null) {
18+
self::$streamFactory = new StreamFactory();
19+
}
20+
21+
return self::$streamFactory;
22+
}
23+
24+
public static function stream(string $content): StreamInterface
25+
{
26+
return self::streamFactory()->createStream($content);
27+
}
28+
}

test/Slack/SlackClientTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use App\Slack\Domain\WebAPIMessage;
1010
use App\Slack\Response\SlackResponse;
1111
use App\Slack\SlackClient;
12+
use AppTest\Psr7Helper;
1213
use PHPUnit\Framework\TestCase;
1314
use Prophecy\Argument;
1415
use Prophecy\PhpUnit\ProphecyTrait;
@@ -59,9 +60,9 @@ public function testSendReturnsReceivedResponseOnSuccess(): void
5960
$response = $this->prophesize(ResponseInterface::class);
6061
$response
6162
->getBody()
62-
->willReturn(json_encode([
63+
->willReturn(Psr7Helper::stream(json_encode([
6364
'ok' => true,
64-
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
65+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)))
6566
->shouldBeCalled();
6667

6768
$this->httpClient
@@ -89,10 +90,10 @@ public function testSendLogsResponseOnFailureBeforeReturning(): void
8990
$response->getStatusCode()->willReturn(400)->shouldBeCalled();
9091
$response
9192
->getBody()
92-
->willReturn(json_encode([
93+
->willReturn(Psr7Helper::stream(json_encode([
9394
'ok' => false,
9495
'error' => 'the error message',
95-
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
96+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)))
9697
->shouldBeCalled();
9798

9899
$this->httpClient
@@ -180,9 +181,9 @@ public function testSendWebhookMessageMarshalsRequestFromMessageAndSendsIt(): vo
180181
$response = $this->prophesize(ResponseInterface::class);
181182
$response
182183
->getBody()
183-
->willReturn(json_encode([
184+
->willReturn(Psr7Helper::stream(json_encode([
184185
'ok' => true,
185-
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
186+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)))
186187
->shouldBeCalled();
187188

188189
$this->httpClient
@@ -257,9 +258,9 @@ public function testSendWebAPIMessageMarshalsRequestFromMessageAndSendsIt(): voi
257258
$response = $this->prophesize(ResponseInterface::class);
258259
$response
259260
->getBody()
260-
->willReturn(json_encode([
261+
->willReturn(Psr7Helper::stream(json_encode([
261262
'ok' => true,
262-
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
263+
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)))
263264
->shouldBeCalled();
264265

265266
$this->httpClient

0 commit comments

Comments
 (0)