From bbb8db61a3ee5ad37b36459af1e9e64b80aa0f79 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 00:59:41 +0000 Subject: [PATCH 1/2] Update dependency psr/http-message to v2 | datasource | package | from | to | | ---------- | ---------------- | ---- | --- | | packagist | psr/http-message | 1.1 | 2.0 | Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index a19a9d5..799b9d6 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ "psr/container": "^1.1.2 || ^2.0.2", "psr/event-dispatcher": "^1.0", "psr/http-factory": "^1.0.2", - "psr/http-message": "^1.1.0", + "psr/http-message": "^2.0.0", "psr/http-server-handler": "^1.0.2", "psr/http-server-middleware": "^1.0.2", "psr/log": "^1.1 || ^2.0 || ^3.0" diff --git a/composer.lock b/composer.lock index 014f959..4ce0f56 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8d781ae40d9acf427a14d4134d9b90f7", + "content-hash": "e0831ac412b6fd69d04883d10304a7d2", "packages": [ { "name": "beberlei/assert", @@ -3646,16 +3646,16 @@ }, { "name": "psr/http-message", - "version": "1.1", + "version": "2.0", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", - "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", "shasum": "" }, "require": { @@ -3664,7 +3664,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -3679,7 +3679,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for HTTP messages", @@ -3693,9 +3693,9 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-message/tree/1.1" + "source": "https://github.com/php-fig/http-message/tree/2.0" }, - "time": "2023-04-04T09:50:52+00:00" + "time": "2023-04-04T09:54:51+00:00" }, { "name": "psr/http-server-handler", From 602358286b3466077c87a7cd016020ab6137f272 Mon Sep 17 00:00:00 2001 From: Aleksei Khudiakov Date: Wed, 6 Dec 2023 14:33:25 +1000 Subject: [PATCH 2/2] Fix test mocks return type Signed-off-by: Aleksei Khudiakov --- .../Listener/DocsBuildActionListenerTest.php | 3 +- ...GitHubReleaseWebsiteUpdateListenerTest.php | 3 +- .../Listener/GitHubStatusListenerTest.php | 7 +++-- .../Listener/RegisterWebhookListenerTest.php | 3 +- test/Psr7Helper.php | 28 +++++++++++++++++++ test/Slack/SlackClientTest.php | 17 +++++------ 6 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 test/Psr7Helper.php diff --git a/test/GitHub/Listener/DocsBuildActionListenerTest.php b/test/GitHub/Listener/DocsBuildActionListenerTest.php index c2f278d..7b0e407 100644 --- a/test/GitHub/Listener/DocsBuildActionListenerTest.php +++ b/test/GitHub/Listener/DocsBuildActionListenerTest.php @@ -10,6 +10,7 @@ use App\Slack\Domain\SlashResponseMessage; use App\Slack\Response\SlackResponse; use App\Slack\SlackClientInterface; +use AppTest\Psr7Helper; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; @@ -81,7 +82,7 @@ public function testLogsErrorAndReportsViaSlackIfGitHubRequestFails(int $httpSta $response = $this->prophesize(ResponseInterface::class); $response->getStatusCode()->willReturn($httpStatus)->shouldBeCalled(); - $response->getBody()->willReturn('error message from github')->shouldBeCalled(); + $response->getBody()->willReturn(Psr7Helper::stream('error message from github'))->shouldBeCalled(); $this->githubClient->send($request->reveal())->will([$response, 'reveal'])->shouldBeCalled(); diff --git a/test/GitHub/Listener/GitHubReleaseWebsiteUpdateListenerTest.php b/test/GitHub/Listener/GitHubReleaseWebsiteUpdateListenerTest.php index 6c8ee23..1641881 100644 --- a/test/GitHub/Listener/GitHubReleaseWebsiteUpdateListenerTest.php +++ b/test/GitHub/Listener/GitHubReleaseWebsiteUpdateListenerTest.php @@ -7,6 +7,7 @@ use App\GitHub\Event\GitHubRelease; use App\GitHub\Listener\GitHubReleaseWebsiteUpdateListener; use App\HttpClientInterface; +use AppTest\Psr7Helper; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; @@ -128,7 +129,7 @@ public function testLogsErrorUpdatingWebsite(): void $response = $this->prophesize(ResponseInterface::class); $response->getStatusCode()->willReturn(400); - $response->getBody()->willReturn(''); + $response->getBody()->willReturn(Psr7Helper::stream('')); $this->httpClient->send($request->reveal())->will([$response, 'reveal'])->shouldBeCalled(); diff --git a/test/GitHub/Listener/GitHubStatusListenerTest.php b/test/GitHub/Listener/GitHubStatusListenerTest.php index cf00cc6..1deb4d7 100644 --- a/test/GitHub/Listener/GitHubStatusListenerTest.php +++ b/test/GitHub/Listener/GitHubStatusListenerTest.php @@ -13,6 +13,7 @@ use App\Slack\Domain\WebAPIMessage; use App\Slack\Response\SlackResponseInterface; use App\Slack\SlackClientInterface; +use AppTest\Psr7Helper; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; @@ -103,7 +104,7 @@ public function testLogsErrorAndNotifiesSlackWithGenericMessageForPullRequestWhe $ghRequest = $this->prophesize(RequestInterface::class); $ghResponse = $this->prophesize(ResponseInterface::class); $ghResponse->getStatusCode()->willReturn(400)->shouldBeCalled(); - $ghResponse->getBody()->willReturn('')->shouldBeCalled(); + $ghResponse->getBody()->willReturn(Psr7Helper::stream(''))->shouldBeCalled(); $this->githubClient ->createRequest( @@ -246,7 +247,7 @@ public function testNotifesSlackWithPullRequestBuildStatusWhenSearchHasAtLeastOn $ghRequest = $this->prophesize(RequestInterface::class); - $ghResponsePayload = json_encode([ + $ghResponsePayload = Psr7Helper::stream(json_encode([ 'incomplete_results' => false, 'items' => [ [ @@ -255,7 +256,7 @@ public function testNotifesSlackWithPullRequestBuildStatusWhenSearchHasAtLeastOn 'html_url' => 'pull-request-url', ], ], - ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); $ghResponse = $this->prophesize(ResponseInterface::class); $ghResponse->getStatusCode()->willReturn(200)->shouldBeCalled(); diff --git a/test/GitHub/Listener/RegisterWebhookListenerTest.php b/test/GitHub/Listener/RegisterWebhookListenerTest.php index 9dc5290..c01a2ad 100644 --- a/test/GitHub/Listener/RegisterWebhookListenerTest.php +++ b/test/GitHub/Listener/RegisterWebhookListenerTest.php @@ -11,6 +11,7 @@ use App\Slack\Response\SlackResponseInterface; use App\Slack\SlackClientInterface; use App\UrlHelper; +use AppTest\Psr7Helper; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; @@ -153,7 +154,7 @@ public function testLogsErrorAndNotifiesSlackWhenWebhookRegistrationFails(): voi $response = $this->prophesize(ResponseInterface::class); $response->getStatusCode()->willReturn(400)->shouldBeCalled(); - $response->getBody()->willReturn(''); + $response->getBody()->willReturn(Psr7Helper::stream('')); $this->github ->createRequest( diff --git a/test/Psr7Helper.php b/test/Psr7Helper.php new file mode 100644 index 0000000..505d7be --- /dev/null +++ b/test/Psr7Helper.php @@ -0,0 +1,28 @@ +createStream($content); + } +} diff --git a/test/Slack/SlackClientTest.php b/test/Slack/SlackClientTest.php index 5fed1ad..a40b451 100644 --- a/test/Slack/SlackClientTest.php +++ b/test/Slack/SlackClientTest.php @@ -9,6 +9,7 @@ use App\Slack\Domain\WebAPIMessage; use App\Slack\Response\SlackResponse; use App\Slack\SlackClient; +use AppTest\Psr7Helper; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; @@ -59,9 +60,9 @@ public function testSendReturnsReceivedResponseOnSuccess(): void $response = $this->prophesize(ResponseInterface::class); $response ->getBody() - ->willReturn(json_encode([ + ->willReturn(Psr7Helper::stream(json_encode([ 'ok' => true, - ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))) ->shouldBeCalled(); $this->httpClient @@ -89,10 +90,10 @@ public function testSendLogsResponseOnFailureBeforeReturning(): void $response->getStatusCode()->willReturn(400)->shouldBeCalled(); $response ->getBody() - ->willReturn(json_encode([ + ->willReturn(Psr7Helper::stream(json_encode([ 'ok' => false, 'error' => 'the error message', - ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))) ->shouldBeCalled(); $this->httpClient @@ -180,9 +181,9 @@ public function testSendWebhookMessageMarshalsRequestFromMessageAndSendsIt(): vo $response = $this->prophesize(ResponseInterface::class); $response ->getBody() - ->willReturn(json_encode([ + ->willReturn(Psr7Helper::stream(json_encode([ 'ok' => true, - ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))) ->shouldBeCalled(); $this->httpClient @@ -257,9 +258,9 @@ public function testSendWebAPIMessageMarshalsRequestFromMessageAndSendsIt(): voi $response = $this->prophesize(ResponseInterface::class); $response ->getBody() - ->willReturn(json_encode([ + ->willReturn(Psr7Helper::stream(json_encode([ 'ok' => true, - ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)) + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))) ->shouldBeCalled(); $this->httpClient