Skip to content

Commit a6fbcc3

Browse files
Add support for PHPUnit 10 & drop support for PHP 7.x (#23)
* Add support for PHPUnit 10 & drop support from PHP 7.x * Allow PHPUnit 10 * Prep for PHPUnit 10 * bump * v5 * PHPUnit 10 support
1 parent dfe594a commit a6fbcc3

14 files changed

+79
-78
lines changed

.github/workflows/php.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,24 @@ jobs:
1212
build:
1313
strategy:
1414
matrix:
15-
php: ['7.2', '7.3', '7.4']
16-
phpunit: ['8.0', '9.0']
17-
composer-arg: ['']
18-
include:
19-
- php: '8.0'
20-
phpunit: '9.0'
21-
composer-arg: 'ignore-platform-req=php'
15+
php: ['8.0', '8.1', '8.2']
16+
phpunit: ['8.0', '9.0', '10.0']
2217
exclude:
2318
- php: '8.0'
24-
phpunit: '8.0'
25-
- php: '7.2'
26-
phpunit: '9.0'
19+
phpunit: '10.0'
2720
runs-on: ubuntu-latest
28-
29-
continue-on-error: ${{ matrix.php == '8.0' }}
3021
name: PHP ${{ matrix.php }}, PHPUnit ${{ matrix.phpunit }}
3122

3223
steps:
3324
- uses: actions/checkout@v1
3425

3526
- name: Setup PHP
36-
uses: shivammathur/setup-php@v1
27+
uses: shivammathur/setup-php@v2
3728
with:
3829
php-version: ${{ matrix.php }}
3930
extensions: mbstring, intl, json
31+
ini-values: error_reporting=E_ALL
4032
coverage: pcov
41-
4233
tools: composer:v2
4334

4435
- name: Validate composer.json and composer.lock
@@ -49,10 +40,10 @@ jobs:
4940
composer require --no-update --dev phpunit/phpunit ~${{ matrix.phpunit }}
5041
5142
- name: Install dependencies
52-
run: composer install --prefer-dist --no-progress --no-suggest --${{ matrix.composer-arg }}
43+
run: composer install --prefer-dist --no-progress --no-suggest
5344

5445
#- name: Run type checker
5546
# run: ./vendor/bin/psalm
5647

5748
- name: Run unit tests
58-
run: ./vendor/bin/phpunit --testdox
49+
run: ./vendor/bin/phpunit --testdox --no-coverage

.github/workflows/php_coverage.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ jobs:
1212
- uses: actions/checkout@v1
1313

1414
- name: Setup PHP
15-
uses: shivammathur/setup-php@v1
15+
uses: shivammathur/setup-php@v2
1616
with:
17-
php-version: 7.4
17+
php-version: 8.0
1818
extensions: mbstring, intl, json
1919
coverage: pcov
20-
20+
2121
- name: Install dependencies
2222
run: composer install --prefer-dist --no-progress --no-suggest
23-
23+
2424
- name: Test & publish code coverage
25-
uses: paambaati/codeclimate-action@v2.3.0
25+
uses: paambaati/codeclimate-action@v3.0.0
2626
env:
2727
CC_TEST_REPORTER_ID: ${{ secrets.codeClimateReporterID }}
2828
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/build/
22
/composer.lock
33
/vendor/
4+
/.phpunit.cache/
45
.phpunit.result.cache
56

67
/.idea/

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ There are several release branches of this library, each of these being compatib
2424
with different releases of PHPUnit and PHP. The following table should give an
2525
easy overview:
2626

27-
| PSR-7 assertion version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 |
28-
| ----------------------- | --------- | --------- | --------- | --------- | --------- | --------- |
29-
| v1 (branch `v1`), **unsupported** | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
30-
| v2 (branch `v2`), **unsupported** | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
31-
| v3 (branch `v3`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: |
32-
| v4 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: |
27+
| PSR-7 assertion version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 | PHPUnit 10 |
28+
| ----------------------- | --------- | --------- | --------- | --------- | --------- | --------- | ---------- |
29+
| v1 (branch `v1`), **unsupported** | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
30+
| v2 (branch `v2`), **unsupported** | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
31+
| v3 (branch `v3`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
32+
| v4 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
3333

3434
When you are using `composer require` and have already declared a dependency to
3535
`phpunit/phpunit` in your `composer.json` file, Composer should pick latest

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
}
1010
],
1111
"require": {
12-
"php": "^7.2 || ^8.0",
12+
"php": "^8.0",
1313
"helmich/phpunit-json-assert": "^3.4",
1414
"psr/http-message": "^1.0"
1515
},
1616
"require-dev": {
1717
"guzzlehttp/psr7": "^1.2",
18-
"phpunit/phpunit": "^8.0 || ^9.0"
18+
"mockery/mockery": "^1.4.1",
19+
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0"
1920
},
2021
"conflict": {
21-
"phpunit/phpunit": "<8.0 || >= 10.0"
22+
"phpunit/phpunit": "<8.0 || >= 11.0"
2223
},
2324
"autoload": {
2425
"psr-4": {

phpunit.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
<?xml version="1.0"?>
12
<phpunit
23
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.1/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
45
bootstrap="vendor/autoload.php"
56
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
97
timeoutForSmallTests="1"
108
timeoutForMediumTests="10"
11-
timeoutForLargeTests="60">
9+
timeoutForLargeTests="60"
10+
cacheDirectory=".phpunit.cache">
1211
<testsuites>
1312
<testsuite name="functional">
1413
<directory>tests/Functional</directory>
@@ -18,13 +17,14 @@
1817
</testsuite>
1918
</testsuites>
2019
<logging>
21-
<log type="coverage-html" target="build/coverage" lowUpperBound="35"
22-
highLowerBound="70"/>
23-
<log type="junit" target="build/phpunit"/>
20+
<junit outputFile="build/phpunit"/>
2421
</logging>
25-
<filter>
26-
<whitelist processUncoveredFilesFromWhitelist="true">
22+
<coverage>
23+
<include>
2724
<directory suffix=".php">src</directory>
28-
</whitelist>
29-
</filter>
25+
</include>
26+
<report>
27+
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
28+
</report>
29+
</coverage>
3030
</phpunit>

src/Functions.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Helmich\Psr7Assert\Constraint\HasHeaderConstraint;
77
use Helmich\Psr7Assert\Constraint\HasUriConstraint;
88
use Helmich\Psr7Assert\Constraint\IsAbsoluteUriConstraint;
9-
use Helmich\Psr7Assert\Psr7Assertions;
9+
use Helmich\Psr7Assert\Psr7AssertionsClass;
1010
use PHPUnit\Framework\Assert;
1111
use PHPUnit\Framework\Constraint\Constraint;
1212

@@ -22,42 +22,42 @@ function hasHeader(string $name, $constraint = null): HasHeaderConstraint
2222

2323
function hasHeaders(array $constraints): Constraint
2424
{
25-
return Psr7Assertions::hasHeaders($constraints);
25+
return Psr7AssertionsClass::hasHeaders($constraints);
2626
}
2727

2828
function hasStatus($status): Constraint
2929
{
30-
return Psr7Assertions::hasStatus($status);
30+
return Psr7AssertionsClass::hasStatus($status);
3131
}
3232

3333
function hasQueryParameter($name, $value = null): Constraint
3434
{
35-
return Psr7Assertions::hasQueryParameter($name, $value);
35+
return Psr7AssertionsClass::hasQueryParameter($name, $value);
3636
}
3737

3838
function hasQueryParameters(array $constraints): Constraint
3939
{
40-
return Psr7Assertions::hasQueryParameters($constraints);
40+
return Psr7AssertionsClass::hasQueryParameters($constraints);
4141
}
4242

4343
function isSuccess(): Constraint
4444
{
45-
return Psr7Assertions::isSuccess();
45+
return Psr7AssertionsClass::isSuccess();
4646
}
4747

4848
function isRedirect(): Constraint
4949
{
50-
return Psr7Assertions::isRedirect();
50+
return Psr7AssertionsClass::isRedirect();
5151
}
5252

5353
function isClientError(): Constraint
5454
{
55-
return Psr7Assertions::isClientError();
55+
return Psr7AssertionsClass::isClientError();
5656
}
5757

5858
function isServerError(): Constraint
5959
{
60-
return Psr7Assertions::isServerError();
60+
return Psr7AssertionsClass::isServerError();
6161
}
6262

6363
function hasContentType(string $contentType): Constraint
@@ -70,27 +70,27 @@ function hasContentType(string $contentType): Constraint
7070

7171
function hasMethod(string $method): Constraint
7272
{
73-
return Psr7Assertions::hasMethod($method);
73+
return Psr7AssertionsClass::hasMethod($method);
7474
}
7575

7676
function isGet(): Constraint
7777
{
78-
return Psr7Assertions::isGet();
78+
return Psr7AssertionsClass::isGet();
7979
}
8080

8181
function isPost(): Constraint
8282
{
83-
return Psr7Assertions::isPost();
83+
return Psr7AssertionsClass::isPost();
8484
}
8585

8686
function isPut(): Constraint
8787
{
88-
return Psr7Assertions::isPut();
88+
return Psr7AssertionsClass::isPut();
8989
}
9090

9191
function isDelete(): Constraint
9292
{
93-
return Psr7Assertions::isDelete();
93+
return Psr7AssertionsClass::isDelete();
9494
}
9595

9696
function bodyMatches($constraint): Constraint
@@ -113,7 +113,7 @@ function bodyMatchesJson($constraints): Constraint
113113

114114
function bodyMatchesForm(array $constraints): Constraint
115115
{
116-
return Psr7Assertions::bodyMatchesForm($constraints);
116+
return Psr7AssertionsClass::bodyMatchesForm($constraints);
117117
}
118118

119119
function isAbsoluteUri(): Constraint

src/Psr7Assertions.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,7 @@ public static function hasHeaders(array $constraints): Constraint
193193
$headerConstraints[] = new HasHeaderConstraint($name, $constraint);
194194
}
195195

196-
$conjunction = Assert::logicalAnd();
197-
$conjunction->setConstraints($headerConstraints);
198-
199-
return $conjunction;
196+
return Assert::logicalAnd(...$headerConstraints);
200197
}
201198

202199
public static function hasHeaderEqualTo(string $name, string $expected): Constraint

src/Psr7AssertionsClass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
declare(strict_types=1);
3+
namespace Helmich\Psr7Assert;
4+
5+
class Psr7AssertionsClass
6+
{
7+
use Psr7Assertions;
8+
}

tests/Functional/ConstraintTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testBodyMatchesJsonCanSucceedWithCharset()
102102
$this->assertMessageBodyMatchesJson($request, array('$.foo' => 'bar'));
103103
}
104104

105-
public function dataForRequestMethods()
105+
public static function dataForRequestMethods()
106106
{
107107
return [
108108
['GET'],
@@ -172,7 +172,7 @@ public function testIsDeleteCanFail()
172172
$this->assertRequestIsDelete(new Request('POST', '/'));
173173
}
174174

175-
public function dataForStatusCodes()
175+
public static function dataForStatusCodes()
176176
{
177177
return [
178178
[200],

0 commit comments

Comments
 (0)