diff --git a/.github/workflows/httpsoft.yml b/.github/workflows/httpsoft.yml new file mode 100644 index 0000000..016f865 --- /dev/null +++ b/.github/workflows/httpsoft.yml @@ -0,0 +1,19 @@ +name: HttpSoft + +on: + push: + branches: + - '*.x' + pull_request: + +jobs: + latest: + strategy: + fail-fast: false + matrix: + php: [ '7.4', '8.0', '8.1', '8.2' ] + uses: ./.github/workflows/integration.yml + with: + php: ${{ matrix.php }} + suite: HttpSoft + package: httpsoft/http-message diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 605523c..a760a4c 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -32,7 +32,7 @@ jobs: # then we install the dependencies # and finally require the implementation to test with source flag (to get integration test cases that might be excluded in git-attributes) run: | - composer remove --dev guzzlehttp/psr7 laminas/laminas-diactoros nyholm/psr7 ringcentral/psr7 slim/psr7 --no-update + composer remove --dev guzzlehttp/psr7 laminas/laminas-diactoros nyholm/psr7 ringcentral/psr7 slim/psr7 httpsoft/http-message --no-update composer require ${{ inputs.package }} --no-interaction --no-progress --prefer-source - name: Execute tests diff --git a/README.md b/README.md index 67e9894..90790a9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ | Slim | [![Slim](https://github.com/php-http/psr7-integration-tests/actions/workflows/slim.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/slim.yml) | | Nyholm | [![Nyholm](https://github.com/php-http/psr7-integration-tests/actions/workflows/nyholm.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/nyholm.yml) | | RingCentral | [![RingCentral](https://github.com/php-http/psr7-integration-tests/actions/workflows/ringcentral.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/ringcentral.yml) | - +| HttpSoft | [![HttpSoft](https://github.com/php-http/psr7-integration-tests/actions/workflows/httpsoft.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/httpsoft.yml) | ## Install diff --git a/composer.json b/composer.json index eea6c4b..02b5705 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "guzzlehttp/psr7": "^1.7 || ^2.0", + "httpsoft/http-message": "^1.1", "laminas/laminas-diactoros": "^2.1", "nyholm/psr7": "^1.0", "ringcentral/psr7": "^1.2", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5722406..1f1884c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -30,6 +30,10 @@ ./vendor/nyholm/psr7/tests/Integration/ + + + ./vendor/httpsoft/http-message/tests/Integration/ + diff --git a/src/BaseTest.php b/src/BaseTest.php index f467bba..aeeb8c4 100644 --- a/src/BaseTest.php +++ b/src/BaseTest.php @@ -5,6 +5,9 @@ use GuzzleHttp\Psr7\Stream as GuzzleStream; use GuzzleHttp\Psr7\UploadedFile as GuzzleUploadedFile; use GuzzleHttp\Psr7\Uri as GuzzleUri; +use HttpSoft\Message\StreamFactory as HttpSoftStreamFactory; +use HttpSoft\Message\UploadedFile as HttpSoftUploadedFile; +use HttpSoft\Message\Uri as HttpSoftUri; use Laminas\Diactoros\StreamFactory as LaminasStreamFactory; use Laminas\Diactoros\Uri as LaminasUri; use Laminas\Diactoros\UploadedFile as LaminasUploadedFile; @@ -47,6 +50,10 @@ protected function buildUri($uri) throw new \RuntimeException('Constant "URI_FACTORY" must be a reference to a Http\Message\UriFactory or \Psr\Http\Message\UriFactoryInterface'); } + if (class_exists(HttpSoftUri::class)) { + return new HttpSoftUri($uri); + } + if (class_exists(GuzzleUri::class)) { return new GuzzleUri($uri); } @@ -98,6 +105,9 @@ protected function buildStream($data) } $factory = null; + if (class_exists(HttpSoftStreamFactory::class)) { + $factory = new HttpSoftStreamFactory(); + } if (class_exists(LaminasStreamFactory::class)) { $factory = new LaminasStreamFactory(); } @@ -136,6 +146,10 @@ protected function buildUploadableFile($data) return $factory->createUploadedFile($stream); } + if (class_exists(HttpSoftUploadedFile::class)) { + return new HttpSoftUploadedFile($data, strlen($data), 0); + } + if (class_exists(GuzzleUploadedFile::class)) { return new GuzzleUploadedFile($data, strlen($data), 0); }