PHPackages                             pschocke/testmacros - 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. pschocke/testmacros

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

pschocke/testmacros
===================

Useful Laravel macros that extend tests

026PHPCI failing

Since Dec 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/pschocke/testmacros)[ Packagist](https://packagist.org/packages/pschocke/testmacros)[ RSS](/packages/pschocke-testmacros/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Test-Macros
===================

[](#laravel-test-macros)

This Package is inspired by Spaties [Laravel Collections](https://github.com/spatie/laravel-collection-macros) package and extends Laravels default Testing methods with a few useful macros.

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

[](#installation)

Via Composer

```
$ composer require pschocke/testmacros --dev
```

The package will automatically register itself.

Macros
------

[](#macros)

### TestResponse

[](#testresponse)

- [`assertResource`](#assertResource)
- [`asArray`](#asArray)
- [`resourceAsArray`](#resourceAsArray)

#### `assertResource`

[](#assertresource)

Asserts that a response is a resource

```
$model = factory(App\Model::class)->create();

$this->json('GET', '/route/to/resource')->assertResource(new ModelResource($model));
```

#### `asArray`

[](#asarray)

Returns the response of a call

```
$responseArray = $this->json('GET', '/route/to/response')->asArray();
```

#### `ResourceAsArray`

[](#resourceasarray)

Returns the data attribute of a API resource response

```
$responseArray = $this->json('GET', '/route/to/resource')->resourceAsArray();
```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

`TODO`

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

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cd89f9905a333779736ad73453f1cfc4c13bf89471e2427975aa43927bb1419?d=identicon)[pschocke](/maintainers/pschocke)

---

Top Contributors

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

---

Tags

laravelmacrosphptesting

### Embed Badge

![Health badge](/badges/pschocke-testmacros/health.svg)

```
[![Health](https://phpackages.com/badges/pschocke-testmacros/health.svg)](https://phpackages.com/packages/pschocke-testmacros)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M679](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M571](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.0k](/packages/orchestra-testbench)

PHPackages © 2026

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