Skip to content

Commit

Permalink
Add httpsoft tests (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored May 25, 2023
1 parent c333566 commit 92ef823
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/httpsoft.yml
Original file line number Diff line number Diff line change
@@ -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
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 --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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

<testsuite name="HttpSoft">
<directory>./vendor/httpsoft/http-message/tests/Integration/</directory>
</testsuite>
</testsuites>

<filter>
Expand Down
14 changes: 14 additions & 0 deletions src/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 92ef823

Please # to comment.