PHPackages                             approvals/approval-tests - 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. approvals/approval-tests

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

approvals/approval-tests
========================

Approval Testing for your legacy projects.

33291.1k↓28%10[5 PRs](https://github.com/approvals/ApprovalTests.php/pulls)PHP

Since Feb 24Pushed 2y ago3 watchersCompare

[ Source](https://github.com/approvals/ApprovalTests.php)[ Packagist](https://packagist.org/packages/approvals/approval-tests)[ RSS](/packages/approvals-approval-tests/feed)WikiDiscussions Main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![build](https://github.com/approvals/ApprovalTests.php/actions/workflows/build.yml/badge.svg)](https://github.com/approvals/ApprovalTests.php/actions/workflows/build.yml)

[![License](https://camo.githubusercontent.com/a549a7a30bacba7bfceebdc207a8e86c3f2c02995a2527640dca30048fd2b64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d626c75652e737667)](https://opensource.org/licenses/Apache-2.0)

**Table of Contents**

- [ApprovalTests.PHP](#approvaltestsphp)
    - [What can it be used for?](#what-can-it-be-used-for)
    - [How to get it](#how-to-get-it)
    - [Video Tutorials](#video-tutorials)
    - [Podcasts](#podcasts)
    - [Examples](#examples)
    - [Approved File Artifacts](#approved-file-artifacts)
    - [More Info](#more-info)
    - [LICENSE](#license)
    - [Questions?](#questions)

ApprovalTests.PHP
=================

[](#approvaltestsphp)

Capturing Human Intelligence - ApprovalTests is an open source assertion/verification library to aid unit testing.

It is compatible with PHPUnit

What can it be used for?
------------------------

[](#what-can-it-be-used-for)

Approval Tests can be used for verifying objects that require more than a simple assert. They also come prepackaged with utilities for some common scenarios including

- HashMaps &amp; Collections
- Long Strings
- Log Files
- Xml
- Html
- Json (see [features](docs/features.md))

How to get it
-------------

[](#how-to-get-it)

It's on [Packagist](https://packagist.org/packages/approvals/approval-tests); search for 'approval-tests'. If you're using Composer, you can add it as follows:

```
composer req --dev approvals/approval-tests
```

[Video Tutorials](http://www.youtube.com/playlist?list=PLFBA98F47156EFAA9&feature=view_all)
-------------------------------------------------------------------------------------------

[](#video-tutorials)

You can watch a bunch of short videos on getting started and [using ApprovalTests](http://www.youtube.com/playlist?list=PLFBA98F47156EFAA9&feature=view_all) at YouTube. These cover approval tests in Java and .NET, but the same concepts apply.

Podcasts
--------

[](#podcasts)

If you prefer auditory learning, you might enjoy the following podcast (Note: Some of these talk about the .Net and Java side)

- [Cucumber Podcast](https://cucumber.io/blog/2017/01/26/approval-testing)
- [Hanselminutes](http://www.hanselminutes.com/360/approval-tests-with-llewellyn-falco)
- [Herding Code](http://www.developerfusion.com/media/122649/herding-code-117-llewellyn-falcon-on-approval-tests/)
- [The Watir Podcast](http://watirpodcast.com/podcast-53/)

Examples
--------

[](#examples)

ApprovalTests eats it own dogfood, so the best examples are in the source code itself.

None the less, Here's a quick look at some [Sample Code](https://github.com/approvals/ApprovalTests.php/blob/9ce5bbd043ea2720bdfe5bbdf25f23a225329485/tests/ApprovalTest.php#L8)

```
class ApprovalTest extends TestCase
{
    public function testVerifyArray()
    {
        $list = ['zero', 'one', 'two', 'three', 'four', 'five'];
        Approvals::verifyList($list);
    }
```

[snippet source](/tests/ApprovalTest.php#L8-L16 "Snippet source file") | [anchor](#snippet-array_example "Start of snippet")

Will Produce a File

```
[0] -> zero
[1] -> one
[2] -> two
[3] -> three
[4] -> four
[5] -> five
```

[snippet source](/tests/approvals/ApprovalTest.testVerifyArray.approved.txt#L1-L6 "Snippet source file") | [anchor](#snippet-tests/approvals/ApprovalTest.testVerifyArray.approved.txt "Start of snippet")

Simply rename this to ApprovalTest.testVerifyArray.approved.txt and the test will now pass.

Approved File Artifacts
-----------------------

[](#approved-file-artifacts)

The `*.approved.*` files must be checked into source your source control. This can be an issue with git as it will change the line endings. The suggested fix is to add `*.approved.* binary` to your `.gitattributes`

More Info
---------

[](#more-info)

- [Website](http://approvaltests.sourceforge.net/)
- [Blog](http://blog.approvaltests.com/)
- [Getting Started Doc](https://github.com/approvals/ApprovalTests.Java/blob/master/build/resources/approval_tests/documentation/ApprovalTests%20-%20GettingStarted.md)

LICENSE
-------

[](#license)

[Apache 2.0 License](https://github.com/SignalR/SignalR/blob/master/LICENSE.md)

Questions?
----------

[](#questions)

twitter: [@LlewellynFalco](https://twitter.com/#!/llewellynfalco) or [@notthatjoshkel](https://twitter.com/notthatjoshkel) or #ApprovalTests

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity46

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5af468831ce52e6ae9d4b43ea4164db6b90a9ce9a93de298b7a92fb12bcc3fda?d=identicon)[llewellyn.falco](/maintainers/llewellyn.falco)

---

Top Contributors

[![joshkel](https://avatars.githubusercontent.com/u/476338?v=4)](https://github.com/joshkel "joshkel (34 commits)")[![mattcan](https://avatars.githubusercontent.com/u/621541?v=4)](https://github.com/mattcan "mattcan (27 commits)")[![isidore](https://avatars.githubusercontent.com/u/10874?v=4)](https://github.com/isidore "isidore (17 commits)")[![underq](https://avatars.githubusercontent.com/u/1336062?v=4)](https://github.com/underq "underq (3 commits)")[![kelleyjd](https://avatars.githubusercontent.com/u/43043927?v=4)](https://github.com/kelleyjd "kelleyjd (1 commits)")

### Embed Badge

![Health badge](/badges/approvals-approval-tests/health.svg)

```
[![Health](https://phpackages.com/badges/approvals-approval-tests/health.svg)](https://phpackages.com/packages/approvals-approval-tests)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/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.9M570](/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.1k](/packages/orchestra-testbench)

PHPackages © 2026

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