diff --git a/composer.json b/composer.json index e432783..eab4b6e 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,8 @@ "ext-iconv": "*", "php-http/client-implementation": "^1.0", "php-http/httplug": "^1.0|^2.0", - "php-http/message-factory": "^1.0", - "psr/http-message": "^1.0" + "psr/http-message": "^2.0", + "psr/http-factory": "^1.0" }, "require-dev": { "phpmd/phpmd": "^2.9.1", @@ -40,5 +40,11 @@ "php-parallel-lint/php-parallel-lint": "^1.2", "egulias/email-validator": "^2.1.23", "symfony/mailer": "^5.0" + }, + "config": { + "allow-plugins": { + "php-http/discovery": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/src/MailhogClient.php b/src/MailhogClient.php index c77abbf..79375bd 100644 --- a/src/MailhogClient.php +++ b/src/MailhogClient.php @@ -1,11 +1,13 @@ httpClient = $client; $this->requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; $this->baseUri = rtrim($baseUri, '/'); } @@ -165,12 +177,10 @@ public function releaseMessage(string $messageId, string $host, int $port, strin $request = $this->requestFactory->createRequest( 'POST', - sprintf('%s/api/v1/messages/%s/release', $this->baseUri, $messageId), - [], - $body + sprintf('%s/api/v1/messages/%s/release', $this->baseUri, $messageId) ); - $this->httpClient->sendRequest($request); + $this->httpClient->sendRequest($request->withBody($this->streamFactory->createStream($body))); } public function getMessageById(string $messageId): Message diff --git a/tests/integration/MailhogClientTest.php b/tests/integration/MailhogClientTest.php index 9502c0f..aaef645 100644 --- a/tests/integration/MailhogClientTest.php +++ b/tests/integration/MailhogClientTest.php @@ -5,7 +5,7 @@ use Generator; use Http\Client\Curl\Client; -use Nyholm\Psr7\Factory\HttplugFactory; +use Nyholm\Psr7\Factory\Psr17Factory; use PHPUnit\Framework\TestCase; use rpkamp\Mailhog\MailhogClient; use rpkamp\Mailhog\Message\Mime\Attachment; @@ -35,7 +35,12 @@ class MailhogClientTest extends TestCase public function setUp(): void { - $this->client = new MailhogClient(new Client(), new HttplugFactory(), $_ENV['mailhog_api_uri']); + $this->client = new MailhogClient( + new Client(), + new Psr17Factory(), + new Psr17Factory(), + $_ENV['mailhog_api_uri'] + ); $this->client->purgeMessages(); } diff --git a/tests/unit/MailhogClientTest.php b/tests/unit/MailhogClientTest.php index a5fb721..02e0617 100644 --- a/tests/unit/MailhogClientTest.php +++ b/tests/unit/MailhogClientTest.php @@ -1,10 +1,11 @@ setAccessible(true);