PHPackages                             helmich/phpunit-json-assert - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. helmich/phpunit-json-assert

ActiveLibrary[Testing &amp; Quality](/categories/testing)

helmich/phpunit-json-assert
===========================

PHPUnit assertions for JSON documents

v3.5.5(2mo ago)1294.2M↓23.3%27[3 issues](https://github.com/martin-helmich/phpunit-json-assert/issues)16MITPHPPHP ^8.1CI passing

Since Dec 13Pushed 2mo ago6 watchersCompare

[ Source](https://github.com/martin-helmich/phpunit-json-assert)[ Packagist](https://packagist.org/packages/helmich/phpunit-json-assert)[ Fund](https://donate.helmich.me)[ GitHub Sponsors](https://github.com/martin-helmich)[ RSS](/packages/helmich-phpunit-json-assert/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (3)Versions (28)Used By (16)

JSON assertions for PHPUnit
===========================

[](#json-assertions-for-phpunit)

[![Unit tests](https://github.com/martin-helmich/phpunit-json-assert/workflows/Unit%20tests/badge.svg)](https://github.com/martin-helmich/phpunit-json-assert/workflows/Unit%20tests/badge.svg)[![Maintainability](https://camo.githubusercontent.com/9fab30e04767af248ccc4d1bdf275b8163d567c36b11e413c173c5099e67895f/68747470733a2f2f716c74792e73682f67682f6d617274696e2d68656c6d6963682f70726f6a656374732f706870756e69742d6a736f6e2d6173736572742f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/martin-helmich/projects/phpunit-json-assert)[![Code Coverage](https://camo.githubusercontent.com/3d70bfefbc4022a499130cbdd905bfa7d619f76398eac834e9b9ec6fd78a66b1/68747470733a2f2f716c74792e73682f67682f6d617274696e2d68656c6d6963682f70726f6a656374732f706870756e69742d6a736f6e2d6173736572742f636f7665726167652e737667)](https://qlty.sh/gh/martin-helmich/projects/phpunit-json-assert)

This library adds several new assertions to [PHPUnit](https://phpunit.de/)that allow you to easily and concisely verify complex data structures (often, but not necessarily, JSON documents) using JSONPath expressions and JSON schemas.

Author and copyright
--------------------

[](#author-and-copyright)

Martin Helmich
This library is [MIT-licensed](LICENSE.txt).

Installation
------------

[](#installation)

```
$ composer require --dev helmich/phpunit-json-assert

```

Compatibility
-------------

[](#compatibility)

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" versionPHPUnit 4PHPUnit 5PHPUnit 6PHPUnit 7PHPUnit 8PHPUnit 9PHPUnit 10PHPUnit 11PHPUnit 12PHPUnit 13v1 (branch `v1`), **unsupported**✅✅🚫🚫🚫🚫🚫🚫🚫🚫v2 (branch `v2`)🚫🚫✅✅🚫🚫🚫🚫🚫🚫v3 (branch `master`)🚫🚫🚫🚫✅✅✅✅✅✅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.

Usage
-----

[](#usage)

Simply use the trait `Helmich\JsonAssert\JsonAssertions` in your test case. This trait offers a set of new `assert*` functions that you can use in your test cases:

```
