diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4313121..0e0b2eb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,8 +4,6 @@ on: push: branches: [master] pull_request: - schedule: - - cron: '39 2 * * 0' jobs: tests: @@ -19,17 +17,15 @@ jobs: ports: - 2025:2025 - 9025:9025 - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 name: Test strategy: fail-fast: false matrix: php: ["7.2", "7.3", "7.4", "8.0"] composer-flags: ["", "--prefer-lowest"] - env: COMPOSER_ROOT_VERSION: dev-master - steps: - uses: actions/checkout@v2 @@ -37,10 +33,10 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: "${{ matrix.php }}" + coverage: pcov - name: Install dependencies run: composer update ${{ matrix.composer-flags }} - name: Run tests run: make test - diff --git a/Makefile b/Makefile index 32ce63a..7ebd738 100644 --- a/Makefile +++ b/Makefile @@ -16,16 +16,16 @@ code-style: phpmd phpcs phpmd: vendor/bin/phpmd src/ xml phpmd.xml --suffixes php -# Check code adheres to PSR-2 +# Check if code adheres to PSR-2 phpcs: vendor/bin/phpcs # Run unit tests unit-tests: ifeq ($(CI),true) - vendor/bin/phpunit --testdox -v --coverage-clover=coverage.xml + vendor/bin/phpunit --coverage-clover=coverage.xml else - vendor/bin/phpunit --testdox -v + vendor/bin/phpunit endif phpstan: diff --git a/composer.json b/composer.json index eab4b6e..5f84878 100644 --- a/composer.json +++ b/composer.json @@ -25,13 +25,13 @@ "ext-json": "*", "ext-iconv": "*", "php-http/client-implementation": "^1.0", - "php-http/httplug": "^1.0|^2.0", - "psr/http-message": "^2.0", + "php-http/httplug": "^1.0 || ^2.0", + "psr/http-message": "^1.0 || ^2.0", "psr/http-factory": "^1.0" }, "require-dev": { "phpmd/phpmd": "^2.9.1", - "phpunit/phpunit": "^8.0", + "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0", "php-http/curl-client": "^2.0", "phpstan/phpstan": "^0.12.64", "pdepend/pdepend": "^2.5", diff --git a/src/MailhogClient.php b/src/MailhogClient.php index 79375bd..af31ff0 100644 --- a/src/MailhogClient.php +++ b/src/MailhogClient.php @@ -7,6 +7,7 @@ use Generator; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamFactoryInterface; use rpkamp\Mailhog\Message\Message; use rpkamp\Mailhog\Message\MessageFactory; @@ -14,6 +15,7 @@ use RuntimeException; use function array_filter; +use function assert; use function count; use function iterator_to_array; use function json_decode; @@ -178,9 +180,16 @@ 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) - ); + )->withBody($this->streamFactory->createStream($body)); + + /** + * Help PHPStan see that this is actually a RequestInterface. withBody is a method + * on MessageInterface and has return type MessageInterface in version 1.0 of psr/http-message. + * This has been fixed in version 2.0 of psr/http-message where the return type is `static`. + */ + assert($request instanceof RequestInterface); - $this->httpClient->sendRequest($request->withBody($this->streamFactory->createStream($body))); + $this->httpClient->sendRequest($request); } public function getMessageById(string $messageId): Message