Skip to content

Commit 13f96eb

Browse files
Added PHPUnit 12 support
1 parent f895811 commit 13f96eb

File tree

7 files changed

+29
-17
lines changed

7 files changed

+29
-17
lines changed

Diff for: .github/workflows/php.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ jobs:
1212
build:
1313
strategy:
1414
matrix:
15-
php: ['8.0', '8.1', '8.2', '8.3']
16-
phpunit: ['8.0', '9.0', '10.0', '11.0']
15+
php: ['8.1', '8.2', '8.3', '8.4']
16+
phpunit: ['8.0', '9.0', '10.0', '11.0', '12.0']
1717
exclude:
18-
- php: '8.0'
19-
phpunit: '10.0'
2018
- php: '8.1'
2119
phpunit: '11.0'
22-
- php: '8.0'
23-
phpunit: '11.0'
20+
- php: '8.1'
21+
phpunit: '12.0'
22+
- php: '8.2'
23+
phpunit: '12.0'
2424
runs-on: ubuntu-latest
2525
name: PHP ${{ matrix.php }}, PHPUnit ${{ matrix.phpunit }}
2626

Diff for: .github/workflows/php_coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Setup PHP
1515
uses: shivammathur/setup-php@v2
1616
with:
17-
php-version: 8.3
17+
php-version: 8.4
1818
extensions: mbstring, intl, json
1919
coverage: pcov
2020

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/build/
22
/composer.lock
33
/vendor/
4-
.phpunit.result.cache
4+
.phpunit.cache
55

66
/.idea/

Diff for: .phpunit.result.cache

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":1,"defects":{"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesSucceedsWithAnyConstraintOnPHPUnit12":1},"times":{"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesFluentTest::testAssertThatJsonDocumentContainsJsonValue":0.005,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesFluentTest::testAssertThatJsonDocumentMatchesJsonConstraints":0.002,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesSchemaFluentTest::testJsonDocumentMatchesSchema":0.004,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesSchemaFluentTest::testJsonDocumentDoesNotMatchSchema":0.002,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesSchemaTest::testJsonDocumentMatchesSchema":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesSchemaTest::testJsonDocumentDoesNotMatchSchema":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesSchemaTest::testStringsAreInterpretedAsJsonString":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #0":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #1":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #2":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #3":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #4":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #5":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #6":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #7":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #8":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #9":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanSucceed with data set #10":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #0":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #1":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #2":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #3":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #4":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #5":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #6":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #7":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #8":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #9":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueEqualsCanFail with data set #10":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #0":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #1":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #2":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #3":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #4":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #5":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #6":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #7":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #8":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #9":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanSucceed with data set #10":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesSucceedsWithAnyConstraint":0.005,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesSucceedsWithAnyConstraintOnPHPUnit12":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #0":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #1":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #2":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #3":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #4":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #5":0.001,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #6":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #7":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #8":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #9":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testJsonValueMatchesCanFail with data set #10":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testAssertThatAllValuesMatch":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testAssertManyCanSucceed":0,"Helmich\\JsonAssert\\Tests\\Functional\\JsonValueMatchesTest::testAssertManyCanFail":0.001}}

Diff for: README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ This library is [MIT-licensed](LICENSE.txt).
2323

2424
There are several release branches of this library, each of these being compatible with different releases of PHPUnit and PHP. The following table should give an easy overview:
2525

26-
| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 | PHPUnit 10 | PHPUnit 11 |
27-
| ------------------------ | --------- | --------- | --------- | --------- | --------- | --------- | ---------- |------------|
28-
| 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: | :no_entry_sign: |
29-
| v2 (branch `v2`) | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
30-
| v3 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
26+
| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 | PHPUnit 10 | PHPUnit 11 | PHPUnit 12 |
27+
| ------------------------ | --------- | --------- | --------- | --------- | --------- | --------- | ---------- |------------|------------|
28+
| 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: | :no_entry_sign: | :no_entry_sign: |
29+
| v2 (branch `v2`) | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: |
30+
| v3 (branch `master`) | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :no_entry_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
3131

3232
When you are using `composer require` and have already declared a dependency to `phpunit/phpunit` in your `composer.json` file, Composer should pick latest compatible version automatically.
3333

Diff for: composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
}
1010
],
1111
"require": {
12-
"php": "^8.0",
12+
"php": "^8.1",
1313
"softcreatr/jsonpath": "^0.8",
1414
"justinrainbow/json-schema": "^5.0"
1515
},
1616
"conflict": {
17-
"phpunit/phpunit": "<8.0 || >= 12.0"
17+
"phpunit/phpunit": "<8.0 || >= 13.0"
1818
},
1919
"require-dev": {
20-
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0"
20+
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0"
2121
},
2222
"autoload": {
2323
"psr-4": {

Diff for: tests/Functional/JsonValueMatchesTest.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
use Helmich\JsonAssert\JsonAssertions;
55
use PHPUnit\Framework\AssertionFailedError;
66
use PHPUnit\Framework\Attributes\DataProvider;
7+
use PHPUnit\Framework\Attributes\RequiresPhpunit;
78
use PHPUnit\Framework\Constraint\Count;
89
use PHPUnit\Framework\Constraint\IsEqual;
910
use PHPUnit\Framework\Constraint\IsType;
11+
use PHPUnit\Framework\NativeType;
1012
use PHPUnit\Framework\TestCase;
13+
use PHPUnit\Runner\Version;
1114

1215
class JsonValueMatchesTest extends TestCase
1316
{
@@ -122,10 +125,18 @@ public function testJsonValueMatchesCanSucceed($jsonDocument, $jsonPath, $expect
122125

123126
public function testJsonValueMatchesSucceedsWithAnyConstraint()
124127
{
128+
$type = 'array';
129+
130+
// Required for PHPUnit 12 support as starting from PHPUnit
131+
// version 12 IsTypeclass expects an enum of NativeType.
132+
if (str_starts_with(Version::id(), '12.')) {
133+
$type = NativeType::Array;
134+
}
135+
125136
$this->assertJsonValueMatches(
126137
static::$exampleDocument,
127138
'$.products',
128-
new IsType('array')
139+
new IsType($type)
129140
);
130141
}
131142

0 commit comments

Comments
 (0)