Skip to content

Commit 92ef823

Browse files
authored
Add httpsoft tests (#73)
1 parent c333566 commit 92ef823

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

.github/workflows/httpsoft.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: HttpSoft
2+
3+
on:
4+
push:
5+
branches:
6+
- '*.x'
7+
pull_request:
8+
9+
jobs:
10+
latest:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '7.4', '8.0', '8.1', '8.2' ]
15+
uses: ./.github/workflows/integration.yml
16+
with:
17+
php: ${{ matrix.php }}
18+
suite: HttpSoft
19+
package: httpsoft/http-message

.github/workflows/integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
# then we install the dependencies
3333
# and finally require the implementation to test with source flag (to get integration test cases that might be excluded in git-attributes)
3434
run: |
35-
composer remove --dev guzzlehttp/psr7 laminas/laminas-diactoros nyholm/psr7 ringcentral/psr7 slim/psr7 --no-update
35+
composer remove --dev guzzlehttp/psr7 laminas/laminas-diactoros nyholm/psr7 ringcentral/psr7 slim/psr7 httpsoft/http-message --no-update
3636
composer require ${{ inputs.package }} --no-interaction --no-progress --prefer-source
3737
3838
- name: Execute tests

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| 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) |
1414
| 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) |
1515
| 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) |
16-
16+
| 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) |
1717

1818
## Install
1919

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"require-dev": {
2222
"guzzlehttp/psr7": "^1.7 || ^2.0",
23+
"httpsoft/http-message": "^1.1",
2324
"laminas/laminas-diactoros": "^2.1",
2425
"nyholm/psr7": "^1.0",
2526
"ringcentral/psr7": "^1.2",

phpunit.xml.dist

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
<testsuite name="Nyholm">
3131
<directory>./vendor/nyholm/psr7/tests/Integration/</directory>
3232
</testsuite>
33+
34+
<testsuite name="HttpSoft">
35+
<directory>./vendor/httpsoft/http-message/tests/Integration/</directory>
36+
</testsuite>
3337
</testsuites>
3438

3539
<filter>

src/BaseTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
use GuzzleHttp\Psr7\Stream as GuzzleStream;
66
use GuzzleHttp\Psr7\UploadedFile as GuzzleUploadedFile;
77
use GuzzleHttp\Psr7\Uri as GuzzleUri;
8+
use HttpSoft\Message\StreamFactory as HttpSoftStreamFactory;
9+
use HttpSoft\Message\UploadedFile as HttpSoftUploadedFile;
10+
use HttpSoft\Message\Uri as HttpSoftUri;
811
use Laminas\Diactoros\StreamFactory as LaminasStreamFactory;
912
use Laminas\Diactoros\Uri as LaminasUri;
1013
use Laminas\Diactoros\UploadedFile as LaminasUploadedFile;
@@ -47,6 +50,10 @@ protected function buildUri($uri)
4750
throw new \RuntimeException('Constant "URI_FACTORY" must be a reference to a Http\Message\UriFactory or \Psr\Http\Message\UriFactoryInterface');
4851
}
4952

53+
if (class_exists(HttpSoftUri::class)) {
54+
return new HttpSoftUri($uri);
55+
}
56+
5057
if (class_exists(GuzzleUri::class)) {
5158
return new GuzzleUri($uri);
5259
}
@@ -98,6 +105,9 @@ protected function buildStream($data)
98105
}
99106

100107
$factory = null;
108+
if (class_exists(HttpSoftStreamFactory::class)) {
109+
$factory = new HttpSoftStreamFactory();
110+
}
101111
if (class_exists(LaminasStreamFactory::class)) {
102112
$factory = new LaminasStreamFactory();
103113
}
@@ -136,6 +146,10 @@ protected function buildUploadableFile($data)
136146
return $factory->createUploadedFile($stream);
137147
}
138148

149+
if (class_exists(HttpSoftUploadedFile::class)) {
150+
return new HttpSoftUploadedFile($data, strlen($data), 0);
151+
}
152+
139153
if (class_exists(GuzzleUploadedFile::class)) {
140154
return new GuzzleUploadedFile($data, strlen($data), 0);
141155
}

0 commit comments

Comments
 (0)