PHPackages                             snailweb/php-tests-helpers - 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. snailweb/php-tests-helpers

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

snailweb/php-tests-helpers
==========================

PHP tests helpers

1.0.3(7y ago)091PHP

Since Mar 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/xavier-rodet/php-tests-helpers)[ Packagist](https://packagist.org/packages/snailweb/php-tests-helpers)[ RSS](/packages/snailweb-php-tests-helpers/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (1)

php-tests-helpers
=================

[](#php-tests-helpers)

Helpers for PHP tests

Usage
-----

[](#usage)

### AccessProtectedTrait

[](#accessprotectedtrait)

Helper to invoke methods and to get/set attributes values with private/protected visibility

```
class MyClassTest
{
    use Snailweb\Helpers\Tests\AccessProtectedTrait;

    public function testMyMethod()
    {
        // Invoke method
        $returnValue = $this->invokeMethod($object, 'methodName', ['arg1', 'arg2']);

        // Get attribute
        $attributeValue = $this->getAttribute($object, 'attributeName');

        // Set attribute
        $this->setAttribute($object, 'attributeName', $attributeValue);
    }
}
```

### TestIteratorTrait

[](#testiteratortrait)

Helper to automatically apply Iterator tests for a class.

Requirements :

- The tested class must implement Iterator (that's the point of doing this ...)
- The tested class constructor must accept no parameters
- The test class must call setUpInterator() with class name, and optionally key name and array name (example shows defaults)

```
class MyClassTest extends TestCase
{
    use Snailweb\Helpers\Tests\TestIteratorTrait;

    public function setUp(): void
    {
        $this->setUpIterator(MyClass::class, 'key', 'array');
    }

    // Do your methods tests
    // ...
}
```

Note: if you need to test the constructor of your class you must do this :

```
class MyClassTest extends TestCase
{
    use Snailweb\Helpers\Tests\TestIteratorTrait{
        testConstruct as testIteratorConstruct;
    }

    public function setUp(): void
    {
        $this->setUpIterator(MyClass::class, 'key', 'array');
    }

    public function testConstruct()
    {
        $this->testIteratorConstruct();

        // Do your constructor tests
        // ...
    }

    // Do your methods tests
    // ...
}
```

### TestSplSubjectTrait

[](#testsplsubjecttrait)

Helper to automatically apply SplSubject tests for a class.

Requirements :

- The tested class must implement SplSubject (that's the point of doing this ...)
- The tested class constructor must accept no parameters
- The test class must call setUpSplSubject() with class name, and optionally observers name (example shows defaults)

```
class MyClassTest extends TestCase
{
    use Snailweb\Helpers\Tests\TestSplSubjectTrait;

    public function setUp(): void
    {
        $this->setUpSplSubject(MyClass::class, 'observers');
    }

    // Do your methods tests
    // ...
}
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~0 days

Total

4

Last Release

2673d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2737842?v=4)[xavier-rodet](/maintainers/xavier-rodet)[@xavier-rodet](https://github.com/xavier-rodet)

---

Top Contributors

[![xavier-rodet](https://avatars.githubusercontent.com/u/2737842?v=4)](https://github.com/xavier-rodet "xavier-rodet (19 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/snailweb-php-tests-helpers/health.svg)

```
[![Health](https://phpackages.com/badges/snailweb-php-tests-helpers/health.svg)](https://phpackages.com/packages/snailweb-php-tests-helpers)
```

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M359](/packages/dms-phpunit-arraysubset-asserts)[phpbenchmark/phpbenchmark

Easy to use benchmark toolkit for your PHP-application. This library contains classes for comparing algorithms as well as benchmarking application responses

8011.5k2](/packages/phpbenchmark-phpbenchmark)

PHPackages © 2026

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