PHPackages                             wheesnoza/assertable-json-enhancer - 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. wheesnoza/assertable-json-enhancer

ActiveLibrary

wheesnoza/assertable-json-enhancer
==================================

A Laravel Assertable Json Enhancer Adding More Assertions Functions.

1.0.0(1y ago)04MITPHPPHP ^8.0

Since Aug 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wheesnoza/assertable-json-enhancer)[ Packagist](https://packagist.org/packages/wheesnoza/assertable-json-enhancer)[ RSS](/packages/wheesnoza-assertable-json-enhancer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

wheesnoza/assertable-json-enhancer
==================================

[](#wheesnozaassertable-json-enhancer)

Available Languages
-------------------

[](#available-languages)

- [English](./README.md)
- [日本語](./README.ja.md)
- [Español](./README.es.md)

`wheesnoza/assertable-json-enhancer` is a package that extends Laravel's `AssertableJson` class. This package enables more flexible and powerful assertions when testing JSON responses. It leverages the `Macroable` trait to provide several useful assertion methods.

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

[](#installation)

You can install this package via Composer:

```
composer require wheesnoza/assertable-json-enhancer
```

Usage
-----

[](#usage)

After installation, this package automatically registers the necessary macros to the `AssertableJson` class. No additional setup is required.

### Compatibility

[](#compatibility)

This package is fully compatible with Laravel Inertia's `AssertableInertia`. You can use the methods provided by `wheesnoza/assertable-json-enhancer` when writing assertions for Inertia responses.

Available Methods
-----------------

[](#available-methods)

### Table of Contents

[](#table-of-contents)

1. [whereStringContains](#1-wherestringcontainsstring-key-string-substring)
2. [whereLessThan](#2-wherelessthanstring-key-int-value)
3. [whereLessThanOrEqual](#3-wherelessthanorequalstring-key-int-value)
4. [whereGreaterThan](#4-wheregreaterthanstring-key-int-value)
5. [whereGreaterThanOrEqual](#5-wheregreaterthanorequalstring-key-int-value)
6. [whereIsArray](#6-whereisarraystring-key)
7. [whereArrayHasAtLeast](#7-wherearrayhasatleaststring-key-int-mincount)
8. [whereArrayHasSize](#8-wherearrayhassizestring-key-int-size)
9. [whereStringStartsWith](#9-wherestringstartswithstring-key-string-prefix)
10. [whereStringEndsWith](#10-wherestringendswithstring-key-string-suffix)
11. [whereExactLength](#11-whereexactlengthstring-key-int-length)
12. [whereMatchesPattern](#12-wherematchespatternstring-key-string-pattern)
13. [whereIsString](#13-whereisstringstring-key)
14. [whereIsInteger](#14-whereisintegerstring-key)
15. [whereIsBoolean](#15-whereisbooleanstring-key)
16. [whereIsFloat](#16-whereisfloatstring-key)
17. [whereIsEmpty](#17-whereisemptystring-key)
18. [whereIsNotEmpty](#18-whereisnotemptystring-key)
19. [whereStringEquals](#19-wherestringequalsstring-key-string-value)
20. [whereStringNotEquals](#20-wherestringnotequalsstring-key-string-value)
21. [whereResultsAreOrderedBy](#21-whereresultsareorderedbystring-key-string-orderkey-string-direction)
22. [whereResultsContain](#22-whereresultscontainstring-key-value)
23. [whereResultsMatchCriteria](#23-whereresultsmatchcriteriastring-key-array-criteria-bool-partialmatch)

### 1. `whereStringContains(string $key, string $substring)`

[](#1-wherestringcontainsstring-key-string-substring)

Asserts that the string at the given key contains the specified substring.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereStringContains('data.name', 'John')
);
```

### 2. `whereLessThan(string $key, int $value)`

[](#2-wherelessthanstring-key-int-value)

Asserts that the value at the given key is less than the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereLessThan('data.age', 18)
);
```

### 3. `whereLessThanOrEqual(string $key, int $value)`

[](#3-wherelessthanorequalstring-key-int-value)

Asserts that the value at the given key is less than or equal to the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereLessThanOrEqual('data.age', 18)
);
```

### 4. `whereGreaterThan(string $key, int $value)`

[](#4-wheregreaterthanstring-key-int-value)

Asserts that the value at the given key is greater than the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereGreaterThan('data.age', 18)
);
```

### 5. `whereGreaterThanOrEqual(string $key, int $value)`

[](#5-wheregreaterthanorequalstring-key-int-value)

Asserts that the value at the given key is greater than or equal to the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereGreaterThanOrEqual('data.age', 18)
);
```

### 6. `whereIsArray(string $key)`

[](#6-whereisarraystring-key)

Asserts that the value at the given key is an array.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsArray('data.items')
);
```

### 7. `whereArrayHasAtLeast(string $key, int $minCount)`

[](#7-wherearrayhasatleaststring-key-int-mincount)

Asserts that the array at the given key has at least the specified number of elements.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereArrayHasAtLeast('data.items', 3)
);
```

### 8. `whereArrayHasSize(string $key, int $size)`

[](#8-wherearrayhassizestring-key-int-size)

Asserts that the array at the given key has exactly the specified number of elements.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereArrayHasSize('data.items', 3)
);
```

### 9. `whereStringStartsWith(string $key, string $prefix)`

[](#9-wherestringstartswithstring-key-string-prefix)

Asserts that the string at the given key starts with the specified prefix.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereStringStartsWith('data.title', 'Laravel')
);
```

### 10. `whereStringEndsWith(string $key, string $suffix)`

[](#10-wherestringendswithstring-key-string-suffix)

Asserts that the string at the given key ends with the specified suffix.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereStringEndsWith('data.title', 'Framework')
);
```

### 11. `whereExactLength(string $key, int $length)`

[](#11-whereexactlengthstring-key-int-length)

Asserts that the string at the given key has exactly the specified length.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereExactLength('data.code', 10)
);
```

### 12. `whereMatchesPattern(string $key, string $pattern)`

[](#12-wherematchespatternstring-key-string-pattern)

Asserts that the string at the given key matches the specified regular expression pattern.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereMatchesPattern('data.email', '/^[\w\-\.]+@([\w\-]+\.)+[\w\-]{2,4}$/')
);
```

### 13. `whereIsString(string $key)`

[](#13-whereisstringstring-key)

Asserts that the value at the given key is a string.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsString('data.name')
);
```

### 14. `whereIsInteger(string $key)`

[](#14-whereisintegerstring-key)

Asserts that the value at the given key is an integer.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsInteger('data.age')
);
```

### 15. `whereIsBoolean(string $key)`

[](#15-whereisbooleanstring-key)

Asserts that the value at the given key is a boolean.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsBoolean('data.active')
);
```

### 16. `whereIsFloat(string $key)`

[](#16-whereisfloatstring-key)

Asserts that the value at the given key is a float.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsFloat('data.price')
);
```

### 17. `whereIsEmpty(string $key)`

[](#17-whereisemptystring-key)

Asserts that the value at the given key is empty (null, empty string, empty array, etc.).

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsEmpty('data.name')
);
```

### 18. `whereIsNotEmpty(string $key)`

[](#18-whereisnotemptystring-key)

Asserts that the value at the given key is not empty.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereIsNotEmpty('data.name')
);
```

### 19. `whereStringEquals(string $key, string $value)`

[](#19-wherestringequalsstring-key-string-value)

Asserts that the string at the given key is exactly equal to the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereStringEquals('data.status', 'active')
);
```

### 20. `whereStringNotEquals(string $key, string $value)`

[](#20-wherestringnotequalsstring-key-string-value)

Asserts that the string at the given key is not equal to the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereStringNotEquals('data.status', 'inactive')
);
```

### 21. `whereResultsAreOrderedBy(string $key, string $orderKey, string $direction = 'asc')`

[](#21-whereresultsareorderedbystring-key-string-orderkey-string-direction--asc)

Asserts that the array at the given key is ordered by the specified key in the given direction.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereResultsAreOrderedBy('data.items', 'id', 'asc')

);
```

### 22. `whereResultsContain(string $key, $value)`

[](#22-whereresultscontainstring-key-value)

Asserts that the array at the given key contains the specified value.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereResultsContain('data.items', 2)
);
```

### 23. `whereResultsMatchCriteria(string $key, array $criteria, bool $partialMatch = false)`

[](#23-whereresultsmatchcriteriastring-key-array-criteria-bool-partialmatch--false)

Asserts that the array at the given key matches the specified criteria. If `partialMatch` is true, it allows partial matching of the criteria values.

```
$response->assertJson(fn (AssertableJson $json) =>
    $json->whereResultsMatchCriteria('data.items', ['name' => 'Laravel'], true)
);
```

Contributing
------------

[](#contributing)

Contributions are welcome! Feel free to submit bug reports or pull requests. If you have any suggestions or improvements, please share them on GitHub.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

620d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/102c4baceae80e613fa1ff6be9b22e90dc076f62743176de6f1c8c86028640e8?d=identicon)[wheesnoza](/maintainers/wheesnoza)

---

Top Contributors

[![wheesnoza](https://avatars.githubusercontent.com/u/45123151?v=4)](https://github.com/wheesnoza "wheesnoza (44 commits)")

---

Tags

phplaravellaravel 9laravel 10laravel 11githubopen-source

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wheesnoza-assertable-json-enhancer/health.svg)

```
[![Health](https://phpackages.com/badges/wheesnoza-assertable-json-enhancer/health.svg)](https://phpackages.com/packages/wheesnoza-assertable-json-enhancer)
```

###  Alternatives

[goodway/laravel-nats

Nats jetstream queue driver with client for Laravel

304.8k](/packages/goodway-laravel-nats)[prismaticoder/maker-checker-laravel

A package for simplifying the integration of a maker-checker approval process to your Laravel application.

232.7k](/packages/prismaticoder-maker-checker-laravel)[novu/novu-laravel

Novu for Laravel

12204.3k](/packages/novu-novu-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
