Skip to content

Added PHPUnit 12 support #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
build:
strategy:
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
phpunit: ['8.0', '9.0', '10.0', '11.0']
php: ['8.1', '8.2', '8.3', '8.4']
phpunit: ['8.0', '9.0', '10.0', '11.0', '12.0']
exclude:
- php: '8.0'
phpunit: '10.0'
- php: '8.1'
phpunit: '11.0'
- php: '8.0'
phpunit: '11.0'
- php: '8.1'
phpunit: '12.0'
- php: '8.2'
phpunit: '12.0'
runs-on: ubuntu-latest
name: PHP ${{ matrix.php }}, PHPUnit ${{ matrix.phpunit }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/php_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4
extensions: mbstring, intl, json
coverage: pcov

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/build/
/composer.lock
/vendor/
.phpunit.result.cache
.phpunit.cache

/.idea/
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +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}}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ This library is [MIT-licensed](LICENSE.txt).

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:

| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 | PHPUnit 10 | PHPUnit 11 |
| ------------------------ | --------- | --------- | --------- | --------- | --------- | --------- | ---------- |------------|
| 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: |
| 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: |
| 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: |
| "JSON assertion" version | PHPUnit 4 | PHPUnit 5 | PHPUnit 6 | PHPUnit 7 | PHPUnit 8 | PHPUnit 9 | PHPUnit 10 | PHPUnit 11 | PHPUnit 12 |
| ------------------------ | --------- | --------- | --------- | --------- | --------- | --------- | ---------- |------------|------------|
| 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: |
| 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: |
| 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: |

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.

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"softcreatr/jsonpath": "^0.8",
"justinrainbow/json-schema": "^5.0"
},
"conflict": {
"phpunit/phpunit": "<8.0 || >= 12.0"
"phpunit/phpunit": "<8.0 || >= 13.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0"
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 12 additions & 1 deletion tests/Functional/JsonValueMatchesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
use Helmich\JsonAssert\JsonAssertions;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpunit;
use PHPUnit\Framework\Constraint\Count;
use PHPUnit\Framework\Constraint\IsEqual;
use PHPUnit\Framework\Constraint\IsType;
use PHPUnit\Framework\NativeType;
use PHPUnit\Framework\TestCase;
use PHPUnit\Runner\Version;

class JsonValueMatchesTest extends TestCase
{
Expand Down Expand Up @@ -122,10 +125,18 @@ public function testJsonValueMatchesCanSucceed($jsonDocument, $jsonPath, $expect

public function testJsonValueMatchesSucceedsWithAnyConstraint()
{
$type = 'array';

// Required for PHPUnit 12 support as starting from PHPUnit
// version 12 IsTypeclass expects an enum of NativeType.
if (str_starts_with(Version::id(), '12.')) {
$type = NativeType::Array;
}

$this->assertJsonValueMatches(
static::$exampleDocument,
'$.products',
new IsType('array')
new IsType($type)
);
}

Expand Down