Skip to content

Commit 2b23d5a

Browse files
committed
move from defunct travis to github workflow
1 parent 5c7ea47 commit 2b23d5a

File tree

11 files changed

+208
-64
lines changed

11 files changed

+208
-64
lines changed

.github/workflows/.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.yml]
2+
indent_size = 2

.github/workflows/guzzle.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Guzzle
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
latest:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
15+
uses: ./.github/workflows/integration.yml
16+
with:
17+
php: ${{ matrix.php }}
18+
suite: Guzzle
19+
package: guzzlehttp/psr7
20+
21+
# - Laminas
22+
# - Slim
23+
# - Nyholm
24+
# - RingCentral

.github/workflows/integration.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
php:
5+
required: true
6+
type: string
7+
suite:
8+
required: true
9+
type: string
10+
package:
11+
required: true
12+
type: string
13+
14+
jobs:
15+
latest:
16+
name: ${{ inputs.suite }} PHP ${{ inputs.php }}
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ inputs.php }}
27+
tools: composer
28+
coverage: none
29+
30+
- name: Install dependencies
31+
# we need to remove all dev dependencies to avoid failures due to php version constraints
32+
# then we install the dependencies
33+
# and finally require the implementation to test with source flag (to get integration test cases that might be excluded in git-attributes)
34+
run: |
35+
composer remove --dev guzzlehttp/psr7 laminas/laminas-diactoros nyholm/psr7 ringcentral/psr7 slim/psr7 --no-update
36+
composer update --no-interaction --no-progress
37+
composer require ${{ inputs.package }} --no-interaction --no-progress --prefer-source
38+
39+
- name: Execute tests
40+
run: composer test -- --testsuite ${{ inputs.suite }}

.github/workflows/laminas.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Laminas
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
latest:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
15+
uses: ./.github/workflows/integration.yml
16+
with:
17+
php: ${{ matrix.php }}
18+
suite: Laminas
19+
package: laminas/laminas-diactoros

.github/workflows/nyholm.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Nyholm
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
latest:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
15+
uses: ./.github/workflows/integration.yml
16+
with:
17+
php: ${{ matrix.php }}
18+
suite: Nyholm
19+
package: nyholm/psr7

.github/workflows/ringcentral.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: RingCentral
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
latest:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
15+
uses: ./.github/workflows/integration.yml
16+
with:
17+
php: ${{ matrix.php }}
18+
suite: RingCentral
19+
package: ringcentral/psr7

.github/workflows/slim.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Slim
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
latest:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php: [ '8.0', '8.1', '8.2' ]
15+
uses: ./.github/workflows/integration.yml
16+
with:
17+
php: ${{ matrix.php }}
18+
suite: Slim
19+
package: slim/psr7

.travis.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

README.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@
88

99
| PSR7 Implementation | Status |
1010
| ------------------- |:-------------:|
11-
| Guzzle | [![Guzzle](https://travis-matrix-badges.herokuapp.com/repos/php-http/psr7-integration-tests/branches/master/1)](https://travis-ci.org/php-http/psr7-integration-tests) |
12-
| Laminas | [![Laminas](https://travis-matrix-badges.herokuapp.com/repos/php-http/psr7-integration-tests/branches/master/2)](https://travis-ci.org/php-http/psr7-integration-tests) |
13-
| Slim | [![Slim](https://travis-matrix-badges.herokuapp.com/repos/php-http/psr7-integration-tests/branches/master/3)](https://travis-ci.org/php-http/psr7-integration-tests) |
14-
| Nyholm | [![Nyholm](https://travis-matrix-badges.herokuapp.com/repos/php-http/psr7-integration-tests/branches/master/4)](https://travis-ci.org/php-http/psr7-integration-tests) |
15-
| RingCentral | [![RingCentral](https://travis-matrix-badges.herokuapp.com/repos/php-http/psr7-integration-tests/branches/master/5)](https://travis-ci.org/php-http/psr7-integration-tests) |
11+
| 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) |
12+
| 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) |
13+
| 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) |
14+
| 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) |
15+
| 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+
1617

1718
## Install
1819

19-
Via Composer
20+
To use the integration tests with a PSR-7 implementation, add this package to the dev dependencies:
2021

2122
``` bash
2223
$ composer require --dev php-http/psr7-integration-tests
2324
```
2425

26+
Then set up phpunit to run the tests for your implementation.
2527

2628
## Documentation
2729

@@ -30,14 +32,26 @@ Please see the [official documentation](http://docs.php-http.org/en/latest).
3032

3133
## Testing
3234

35+
This repository also is set up to test a couple of implementations directly. You need to install dependencies from source for the tests to work:
36+
37+
``` bash
38+
$ composer update --prefer-source
39+
```
40+
41+
**Note:** If you already have the sources installed, you need to delete the vendor folder before running the above command.
42+
43+
Run the test suite for one implementation with:
44+
3345
``` bash
34-
$ composer test
46+
$ composer test -- --testsuite <name>
3547
```
3648

49+
The names are `Guzzle`, `Laminas`, `Slim`, `Nyholm`, `RingCentral`.
50+
3751
It is also possible to exclude tests that require a live internet connection:
3852

3953
``` bash
40-
$ composer test -- --exclude-group internet
54+
$ composer test -- --testsuite <name> --exclude-group internet
4155
```
4256

4357
## Contributing

src/BaseTest.php

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
use GuzzleHttp\Psr7\Stream as GuzzleStream;
66
use GuzzleHttp\Psr7\UploadedFile as GuzzleUploadedFile;
77
use GuzzleHttp\Psr7\Uri as GuzzleUri;
8+
use Laminas\Diactoros\Stream as LaminasStream;
9+
use Laminas\Diactoros\Uri as LaminasUri;
10+
use Laminas\Diactoros\UploadedFile as LaminasUploadedFile;
11+
use Nyholm\Psr7\Factory\Psr17Factory as NyholmFactory;
812
use PHPUnit\Framework\TestCase;
913
use Psr\Http\Message\UriInterface;
14+
use RingCentral\Psr7\Uri as RingCentralUri;
15+
use function RingCentral\Psr7\stream_for as ring_central_stream_for;
1016
use Slim\Psr7\Uri as SlimUri;
11-
use Zend\Diactoros\Stream as ZendStream;
12-
use Zend\Diactoros\Uri as ZendUri;
13-
use Zend\Diactoros\UploadedFile as ZendUploadedFile;
17+
use Slim\Psr7\Factory\UriFactory as SlimUriFactory;
1418

1519
/**
1620
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
@@ -46,11 +50,22 @@ protected function buildUri($uri)
4650
}
4751

4852
if (class_exists(SlimUri::class)) {
53+
if (class_exists(SlimUriFactory::class)) {
54+
return (new SlimUriFactory())->createUri($uri);
55+
}
4956
return SlimUri::createFromString($uri);
5057
}
5158

52-
if (class_exists(ZendUri::class)) {
53-
return new ZendUri($uri);
59+
if (class_exists(LaminasUri::class)) {
60+
return new LaminasUri($uri);
61+
}
62+
63+
if (class_exists(NyholmFactory::class)) {
64+
return (new NyholmFactory())->createUri($uri);
65+
}
66+
67+
if (class_exists(RingCentralUri::class)) {
68+
return new RingCentralUri($uri);
5469
}
5570

5671
throw new \RuntimeException('Could not create URI. Check your config');
@@ -67,9 +82,8 @@ protected function buildStream($data)
6782
if ($factory instanceof \Psr\Http\Message\StreamFactoryInterface) {
6883
if (is_string($data)) {
6984
return $factory->createStream($data);
70-
} else {
71-
return $factory->createStreamFromResource($data);
7285
}
86+
return $factory->createStreamFromResource($data);
7387
}
7488

7589
throw new \RuntimeException('Constant "STREAM_FACTORY" must be a reference to a Http\Message\StreamFactory or \Psr\Http\Message\StreamFactoryInterface');
@@ -79,8 +93,19 @@ protected function buildStream($data)
7993
return \GuzzleHttp\Psr7\Utils::streamFor($data);
8094
}
8195

82-
if (class_exists(ZendStream::class)) {
83-
return new ZendStream($data);
96+
if (class_exists(LaminasStream::class)) {
97+
return new LaminasStream($data);
98+
}
99+
100+
if (class_exists(NyholmFactory::class)) {
101+
if (is_string($data)) {
102+
return (new NyholmFactory())->createStream($data);
103+
}
104+
return (new NyholmFactory())->createStreamFromResource($data);
105+
}
106+
107+
if (function_exists('ring_central_stream_for')) {
108+
return ring_central_stream_for($data);
84109
}
85110

86111
throw new \RuntimeException('Could not create Stream. Check your config');
@@ -104,8 +129,14 @@ protected function buildUploadableFile($data)
104129
return new GuzzleUploadedFile($data, strlen($data), 0);
105130
}
106131

107-
if (class_exists(ZendUploadedFile::class)) {
108-
return new ZendUploadedFile($data, strlen($data), 0);
132+
if (class_exists(LaminasUploadedFile::class)) {
133+
return new LaminasUploadedFile($data, strlen($data), 0);
134+
}
135+
136+
if (class_exists(NyholmFactory::class)) {
137+
$stream = $this->buildStream($data);
138+
139+
return (new NyholmFactory())->createUploadedFile($stream);
109140
}
110141

111142
throw new \RuntimeException('Could not create Stream. Check your config');

tests/RingCentral/StreamTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
namespace Http\Psr7Test\Tests\RingCentral;
44

55
use Http\Psr7Test\StreamIntegrationTest;
6+
use function RingCentral\Psr7\stream_for;
67

78
class StreamTest extends StreamIntegrationTest
89
{
910
public function createStream($data)
1011
{
11-
return \RingCentral\Psr7\Utils::streamFor($data);
12+
return stream_for($data);
1213
}
1314
}

0 commit comments

Comments
 (0)