diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1ebc88b..3d70184 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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 }} diff --git a/.github/workflows/php_coverage.yml b/.github/workflows/php_coverage.yml index bf3c8bb..3e89f2b 100644 --- a/.github/workflows/php_coverage.yml +++ b/.github/workflows/php_coverage.yml @@ -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 diff --git a/.gitignore b/.gitignore index b7878e0..502035d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /build/ /composer.lock /vendor/ -.phpunit.result.cache +.phpunit.cache /.idea/ diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..b43b6b9 --- /dev/null +++ b/.phpunit.result.cache @@ -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}} \ No newline at end of file diff --git a/README.md b/README.md index 03255cc..27c40bc 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/composer.json b/composer.json index ba6b57d..06ff379 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/tests/Functional/JsonValueMatchesTest.php b/tests/Functional/JsonValueMatchesTest.php index a5a2da4..be40b86 100644 --- a/tests/Functional/JsonValueMatchesTest.php +++ b/tests/Functional/JsonValueMatchesTest.php @@ -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 { @@ -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) ); }