PHPackages                             lelinea/api-snapshot-testing - 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. lelinea/api-snapshot-testing

ActiveLibrary

lelinea/api-snapshot-testing
============================

Provides PHPUnit assertions for api snapshot testing

v1.6.1(1y ago)230.9k↑167.5%MITPHPPHP &gt;=8.1

Since May 6Pushed 1y ago2 watchersCompare

[ Source](https://github.com/LelineaITManufaktur/api-snapshot-testing)[ Packagist](https://packagist.org/packages/lelinea/api-snapshot-testing)[ RSS](/packages/lelinea-api-snapshot-testing/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (9)Versions (18)Used By (0)

Snapshot Testing
================

[](#snapshot-testing)

[![Build Status](https://camo.githubusercontent.com/b2dc88c075284d717768294d49232ce4e4cef9f12f63b07b679b666512eb028d/68747470733a2f2f7472617669732d63692e6f72672f4c656c696e656149544d616e7566616b7475722f6170692d736e617073686f742d74657374696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/LelineaITManufaktur/api-snapshot-testing)

Provides PHPUnit assertions for snapshot testing

### Installation

[](#installation)

```
composer require --dev lelinea/snapshot-testing

```

### Basic Usage

[](#basic-usage)

```
use Lelinea\ApiSnapshotTesting\MatchesSnapshots;

final class MyUnitTest extends TestCase
{
    use MatchesSnapshots;

    public function testJson()
    {
        $myJsonData = json_encode([
            'foo' => 'bar',
        ]);

        $this->assertMatchesJsonSnapshot($myJsonData, 'localhost/json-test-route');
    }

    public function testXml()
    {
        $myXmlData = "7d644cc6-70fa-11e9-89e1-220d3e3a2561";

        $this->assertMatchesXmlSnapshot($myXmlData, 'localhost/xml-test-route');
    }

    public function testCsv()
    {
        $myCsvData =  'bar',
        ]);

        $this->assertMatchesJsonSnapshot($myJsonData, 'localhost/json-test-route', [
            new UuidWildcard('id'),
        ]);
    }

    public function testXml()
    {
        $myXmlData = '7d644cc6-70fa-11e9-89e1-220d3e3a2561';

        $this->assertMatchesXmlSnapshot($myXmlData, 'localhost/xml-test-route', [
            new UuidWildcard('id'),
        ]);
    }
}
```

This ignores the concrete uuid given for the field "id" and only checks that a valid uuid is provided.

The library currently supports the following wildcards:

- BooleanWildcard
- IntegerWildcard
- UuidWildcard
- UuidOrNullWildcard
- DateTimeWildcard
- DateTimeOrNullWildcard
- StringWildcard
- StringOrNullWildcard

### Usage in CI

[](#usage-in-ci)

When running your tests in Continuous Integration you would possibly want to disable the creation of snapshots.

By using the --without-creating-snapshots parameter, PHPUnit will fail if the snapshots don't exist.

```
> ./vendor/bin/phpunit -d --without-creating-snapshots

1) ExampleTest::test_it_matches_a_string
Snapshot "ExampleTest__test_it_matches_a_string__1.txt" does not exist.
You can automatically create it by removing `-d --without-creating-snapshots` of PHPUnit's CLI arguments.

```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~128 days

Recently: every ~255 days

Total

17

Last Release

523d ago

Major Versions

0.4.0 → 1.0.02020-11-22

PHP version history (3 changes)0.1PHP ^7.1

0.4.0PHP ^7.4

v1.5.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f8da6e14f5aed5796df32098aa59a8d8ce3be8b6013be11890821ae45ab340b?d=identicon)[hnnnglmbrg](/maintainers/hnnnglmbrg)

---

Top Contributors

[![hnnnglmbrg](https://avatars.githubusercontent.com/u/1747293?v=4)](https://github.com/hnnnglmbrg "hnnnglmbrg (36 commits)")[![n0-m4d](https://avatars.githubusercontent.com/u/11576763?v=4)](https://github.com/n0-m4d "n0-m4d (26 commits)")[![dmecke](https://avatars.githubusercontent.com/u/1172148?v=4)](https://github.com/dmecke "dmecke (24 commits)")[![bitladen-jw](https://avatars.githubusercontent.com/u/13119489?v=4)](https://github.com/bitladen-jw "bitladen-jw (1 commits)")

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/lelinea-api-snapshot-testing/health.svg)

```
[![Health](https://phpackages.com/badges/lelinea-api-snapshot-testing/health.svg)](https://phpackages.com/packages/lelinea-api-snapshot-testing)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M263](/packages/ssch-typo3-rector)

PHPackages © 2026

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