From 542fba210ee8289e77cf2f877ad9abbe7f917578 Mon Sep 17 00:00:00 2001 From: ikkez Date: Fri, 3 Jan 2025 12:52:31 +0100 Subject: [PATCH 1/2] feat: add fatfree PSR7 package --- .github/workflows/fatfree.yml | 19 +++++++++++++++++++ .github/workflows/integration.yml | 2 +- README.md | 17 +++++++++-------- composer.json | 1 + phpunit.xml.dist | 4 +++- 5 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/fatfree.yml diff --git a/.github/workflows/fatfree.yml b/.github/workflows/fatfree.yml new file mode 100644 index 0000000..4efae5d --- /dev/null +++ b/.github/workflows/fatfree.yml @@ -0,0 +1,19 @@ +name: Fatfree + +on: + push: + branches: + - '*.x' + pull_request: + +jobs: + latest: + strategy: + fail-fast: false + matrix: + php: [ '8.0', '8.1', '8.2', '8.3' ] + uses: ./.github/workflows/integration.yml + with: + php: ${{ matrix.php }} + suite: Fatfree + package: f3-factory/fatfree-psr7 diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 461df62..1d51e5a 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 httpsoft/http-message --no-update + composer remove --dev guzzlehttp/psr7 laminas/laminas-diactoros nyholm/psr7 ringcentral/psr7 slim/psr7 httpsoft/http-message f3-factory/fatfree-psr7 --no-update composer require ${{ inputs.package }} --no-interaction --no-progress --prefer-source - name: Execute tests diff --git a/README.md b/README.md index 90790a9..7b17ed9 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,15 @@ ## Status -| PSR7 Implementation | Status | Legacy | -| ------------------- |:-------------:|:------:| -| Guzzle | [![Guzzle](https://github.com/php-http/psr7-integration-tests/actions/workflows/guzzle.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/guzzle.yml) | -| Laminas | [![Laminas](https://github.com/php-http/psr7-integration-tests/actions/workflows/laminas.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/laminas.yml) | [Legacy](https://github.com/php-http/psr7-integration-tests/actions/workflows/laminas-legacy.yml) (failures expected) | -| 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) | +| PSR7 Implementation | Status | Legacy | +|---------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------:| +| Guzzle | [![Guzzle](https://github.com/php-http/psr7-integration-tests/actions/workflows/guzzle.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/guzzle.yml) | +| Laminas | [![Laminas](https://github.com/php-http/psr7-integration-tests/actions/workflows/laminas.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/laminas.yml) | [Legacy](https://github.com/php-http/psr7-integration-tests/actions/workflows/laminas-legacy.yml) (failures expected) | +| 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) | +| 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) | +| Fatfree | [![HttpSoft](https://github.com/php-http/psr7-integration-tests/actions/workflows/fatfree.yml/badge.svg)](https://github.com/php-http/psr7-integration-tests/actions/workflows/fatfree.yml) | ## Install @@ -46,7 +47,7 @@ Run the test suite for one implementation with: $ composer test -- --testsuite ``` -The names are `Guzzle`, `Laminas`, `Slim`, `Nyholm`, `RingCentral`. +The names are `Guzzle`, `Laminas`, `Slim`, `Nyholm`, `RingCentral`, `HttpSoft`, `Fatfree`. It is also possible to exclude tests that require a live internet connection: diff --git a/composer.json b/composer.json index 666e830..cee5f90 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "psr/http-message": "^1.0 || ^2.0" }, "require-dev": { + "f3-factory/fatfree-psr7": "^2.0", "guzzlehttp/psr7": "^1.7 || ^2.0", "httpsoft/http-message": "^1.1", "laminas/laminas-diactoros": "^2.1", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f828cf8..6915517 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -31,9 +31,11 @@ ./vendor/nyholm/psr7/tests/Integration/ - ./vendor/httpsoft/http-message/tests/Integration/ + + ./vendor/f3-factory/fatfree-psr7/tests/Integration/ + From 6d2577642554a9a08bf51d39438725b9900c13fb Mon Sep 17 00:00:00 2001 From: ikkez Date: Sat, 4 Jan 2025 00:00:04 +0100 Subject: [PATCH 2/2] fix: test factory initialization --- src/BaseTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/BaseTest.php b/src/BaseTest.php index f126eca..8df5714 100644 --- a/src/BaseTest.php +++ b/src/BaseTest.php @@ -2,6 +2,7 @@ namespace Http\Psr7Test; +use F3\Http\Factory\Psr17Factory as FatfreeFactory; use GuzzleHttp\Psr7\Stream as GuzzleStream; use GuzzleHttp\Psr7\UploadedFile as GuzzleUploadedFile; use GuzzleHttp\Psr7\Uri as GuzzleUri; @@ -84,6 +85,10 @@ protected function buildUri($uri) return new RingCentralUri($uri); } + if (class_exists(FatfreeFactory::class)) { + return (new FatfreeFactory())->createUri($uri); + } + throw new \RuntimeException('Could not create URI. Check your config'); } @@ -123,6 +128,9 @@ protected function buildStream($data) if (class_exists(SlimStreamFactory::class)) { $factory = new SlimStreamFactory(); } + if (class_exists(FatfreeFactory::class)) { + $factory = new FatfreeFactory(); + } if ($factory) { if (is_string($data)) { return $factory->createStream($data); @@ -176,6 +184,12 @@ protected function buildUploadableFile($data) return (new SlimUploadedFileFactory())->createUploadedFile($stream); } + if (class_exists(FatfreeFactory::class)) { + $stream = $this->buildStream($data); + + return (new FatfreeFactory())->createUploadedFile($stream); + } + throw new \RuntimeException('Could not create Stream. Check your config'); } }