Skip to content

add Fatfree PSR7 package #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/fatfree.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -46,7 +47,7 @@ Run the test suite for one implementation with:
$ composer test -- --testsuite <name>
```

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:

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
<testsuite name="Nyholm">
<directory>./vendor/nyholm/psr7/tests/Integration/</directory>
</testsuite>

<testsuite name="HttpSoft">
<directory>./vendor/httpsoft/http-message/tests/Integration/</directory>
</testsuite>
<testsuite name="Fatfree">
<directory>./vendor/f3-factory/fatfree-psr7/tests/Integration/</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 14 additions & 0 deletions src/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
}
}
Loading