PHPackages                             symplify/easy-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. [Testing &amp; Quality](/categories/testing)
4. /
5. symplify/easy-testing

AbandonedArchivedSymfony-bundle[Testing &amp; Quality](/categories/testing)

symplify/easy-testing
=====================

Testing made easy

11.1.26(3y ago)417.7M↓22.3%315MITPHPPHP &gt;=8.1

Since Jun 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/deprecated-packages/easy-testing)[ Packagist](https://packagist.org/packages/symplify/easy-testing)[ Fund](https://www.paypal.me/rectorphp)[ GitHub Sponsors](https://github.com/tomasvotruba)[ RSS](/packages/symplify-easy-testing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (17)Versions (387)Used By (15)

Testing Made Easy
=================

[](#testing-made-easy)

[![Downloads total](https://camo.githubusercontent.com/87a372396b8815f5705eecafb50d50fe35614d7dc5acce92022932fb6eefd5ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73796d706c6966792f656173792d74657374696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/symplify/easy-testing/stats)

Install
-------

[](#install)

```
composer require symplify/easy-testing --dev
```

Usage
-----

[](#usage)

### Easier working with Fixtures

[](#easier-working-with-fixtures)

Do you use unit fixture file format?

```
echo 'content before';

?>
-----

```

Or in case of no change at all:

```
echo 'just this content';
```

The code is separated by `-----`. Top half of the file is input, the 2nd half is expected output.

It is common to organize test fixture in the test directory:

```
/tests/SomeTest/Fixture/added_comma.php.inc
/tests/SomeTest/Fixture/skip_alreay_added_comma.php.inc
```

How this package makes it easy to work with them? 2 classes:

- `Symplify\EasyTesting\DataProvider\StaticFixtureFinder`
- `Symplify\EasyTesting\StaticFixtureSplitter`

```
// tests/SomeTest/SomeTest.php

namespace App\Tests\SomeTest;

use Iterator;
use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;
use Symplify\EasyTesting\StaticFixtureSplitter;
use Symplify\SmartFileSystem\SmartFileInfo;

final class SomeTest extends TestCase
{
    /**
     * @dataProvider provideData()
     */
    public function test(SmartFileInfo $fileInfo): void
    {
        $inputAndExpected = StaticFixtureSplitter::splitFileInfoToInputAndExpected($fileInfo);

        // test before content
        $someService = new SomeService();
        $changedContent = $someService->process($inputAndExpected->getInput());

        $this->assertSame($inputAndExpected->getExpected(), $changedContent);
    }

    public function provideData(): Iterator
    {
        return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture');
    }
}
```

Features
--------

[](#features)

Do you need the input code to be in separated files? E.g. to test the file was moved?

Instead of `splitFileInfoToInputAndExpected()` use `splitFileInfoToLocalInputAndExpectedFileInfos()`:

```
-$inputAndExpected = StaticFixtureSplitter::splitFileInfoToInputAndExpected(
+$inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
    $fileInfo
 );
```

Compared to formated method, `splitFileInfoToLocalInputAndExpectedFileInfos()` will:

- separate fixture to input and expected content
- save them both as separated files to temporary path
- optionally autoload the first one, e.g. if you need it for Reflection

```
use Symplify\EasyTesting\StaticFixtureSplitter;

$inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
    $fileInfo,
    true
);
```

By default, the `StaticFixtureFinder` finds only `*.php.inc` files.

```
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;

return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture');
```

In case you use different files, e.g. `*.twig` or `*.md`, change it in 2nd argument:

```
use Symplify\EasyTesting\DataProvider\StaticFixtureFinder;

return StaticFixtureFinder::yieldDirectory(__DIR__ . '/Fixture', '*.md');
```

Updating Fixture
----------------

[](#updating-fixture)

[How to Update Hundreds of Test Fixtures with Single PHPUnit run](https://tomasvotruba.com/blog/2020/07/20/how-to-update-hundreds-of-test-fixtures-with-single-phpunit-run/)?

If you change an output of your software on purpose, you might want to update your fixture. Manually? No, from command line:

```
UPDATE_TESTS=1 vendor/bin/phpunit
UT=1 vendor/bin/phpunit
```

To make this work, we have to add `StaticFixtureUpdater::updateFixtureContent()` call to our test case:

```
use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater;
use Symplify\EasyTesting\StaticFixtureSplitter;
use Symplify\SmartFileSystem\SmartFileInfo;

final class SomeTestCase extends TestCase
{
    /**
     * @dataProvider provideData()
     */
    public function test(SmartFileInfo $fixtureFileInfo): void
    {
        $inputFileInfoAndExpectedFileInfo = StaticFixtureSplitter::splitFileInfoToLocalInputAndExpectedFileInfos(
            $fixtureFileInfo
        );

        // process content
        $currentContent = '...';

        // here we update test fixture if the content changed
        StaticFixtureUpdater::updateFixtureContent(
            $inputFileInfoAndExpectedFileInfo->getInputFileInfo(),
            $currentContent,
            $fixtureFileInfo
        );
    }

    // data provider...
}
```

Assert 2 Directories by Files and Content
-----------------------------------------

[](#assert-2-directories-by-files-and-content)

Do you generate large portion of files? Do you want to skip nitpicking tests file by file?

Use `assertDirectoryEquals()` method to validate the files and their content is as expected.

```
use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\PHPUnit\Behavior\DirectoryAssertableTrait;

final class DirectoryAssertableTraitTest extends TestCase
{
    use DirectoryAssertableTrait;

    public function testSuccess(): void
    {
        $this->assertDirectoryEquals(__DIR__ . '/Fixture/first_directory', __DIR__ . '/Fixture/second_directory');
    }
}
```

Report Issues
-------------

[](#report-issues)

In case you are experiencing a bug or want to request a new feature head over to the [Symplify monorepo issue tracker](https://github.com/symplify/symplify/issues)

Contribute
----------

[](#contribute)

The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on [symplify/symplify](https://github.com/symplify/symplify).

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 95% 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

Every ~2 days

Recently: every ~11 days

Total

386

Last Release

1198d ago

Major Versions

8.3.48 → 9.0.0-BETA12020-11-14

9.4.70 → 10.0.0-beta12021-11-02

10.3.3 → 11.0.02022-06-13

PHP version history (6 changes)v8.1.0PHP ^7.2

8.2.17PHP ^7.2|^8.0

8.3.0PHP &gt;=7.2

9.0.0-rc1PHP &gt;=7.3

v9.3.27PHP &gt;=8.0

11.1.11PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/924196?v=4)[Tomas Votruba](/maintainers/TomasVotruba)[@TomasVotruba](https://github.com/TomasVotruba)

---

Top Contributors

[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (453 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (17 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (7 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisRector

Code StyleECS

### Embed Badge

![Health badge](/badges/symplify-easy-testing/health.svg)

```
[![Health](https://phpackages.com/badges/symplify-easy-testing/health.svg)](https://phpackages.com/packages/symplify-easy-testing)
```

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[phpbench/phpbench

PHP Benchmarking Framework

2.0k13.0M627](/packages/phpbench-phpbench)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

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

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[sulu/sulu

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

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

PHPackages © 2026

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