PHPackages                             atanvarno/test-util - 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. atanvarno/test-util

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

atanvarno/test-util
===================

PHPUnit test case utilities

0.1.1(4y ago)01021MITPHPPHP ^7.0|^8.0

Since May 6Pushed 4y agoCompare

[ Source](https://github.com/atanvarno69/test-util)[ Packagist](https://packagist.org/packages/atanvarno/test-util)[ Docs](https://github.com/atanvarno69/test-util)[ RSS](/packages/atanvarno-test-util/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (2)DependenciesVersions (3)Used By (1)

Atanvarno\\PHPUnit
==================

[](#atanvarnophpunit)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/atanvarno69/test-util/blob/master/LICENSE)[![Latest Version](https://camo.githubusercontent.com/03cc306bd3ceec7d49540294bad42f76833191a72032858132a6ca127b7c58fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6174616e7661726e6f36392f746573742d7574696c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/atanvarno69/test-util/releases)

Utility traits for [PHPUnit](https://phpunit.de/) test cases for interacting with protected and private methods and properties.

Requirements
------------

[](#requirements)

**PHP &gt;= 7.0** is required, but the latest stable version of PHP is recommended.

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

[](#installation)

```
$ composer require atanvarno/test-util:^0.1.0
```

Basic Usage
-----------

[](#basic-usage)

```
class YourTest extends \PHPUnit\Framework\TestCase
{
    // Include the traits
    use Atanvarno\PHPUnit\{CallProtectedMethodTrait, SetProtectedPropertyTrait};

    // Write your tests
    public function testYourMethod()
    {
        $testObject = new SomeClass();

        // Set an inaccessible property
        $this->setProtectedProperty($testObject, 'propertyName', 'value');

        // Call an inaccessible method
        $result = $this->callProtectedMethod(
            $testObject,
            'methodName',
            ['argument 1', 'argument 2', '...']
        );

        // Do your assertations
        // ...
    }
}
```

Atanvarno\\PHPUnit\\CallProtectedMethodTrait
--------------------------------------------

[](#atanvarnophpunitcallprotectedmethodtrait)

Provides means to call a protected or private method of an object for test purposes.

```
public function callProtectedMethod($object, string $method, array $arguments = [])
```

Calls a protected or private method and returns its result.

### Parameters

[](#parameters)

- `object` **$object**

    Required. The instance containing the method to call.
- `string` **$method**

    Required. The method name.
- `mixed[]` **$arguments**

    Optional. Defaults to `[]`. Arguments to pass to the method.

### Throws

[](#throws)

- [`InvalidArgumentException`](http://php.net/manual/en/class.invalidargumentexception.php)

    Non-object passed as first parameter.

### Returns

[](#returns)

- `mixed`

    The return value of the method call.

Atanvarno\\PHPUnit\\SetProtectedPropertyTrait
---------------------------------------------

[](#atanvarnophpunitsetprotectedpropertytrait)

Provides means to set a protected or private property of an object for test purposes.

```
public function setProtectedProperty($object, string $property, $value)
```

Sets a protected or private property.

### Parameters

[](#parameters-1)

- `object` **$object**

    Required. The instance containing the property to set.
- `string` **$property**

    Required. The property name.
- `mixed` **$value**

    Required. The value to set.

### Throws

[](#throws-1)

- [`InvalidArgumentException`](http://php.net/manual/en/class.invalidargumentexception.php)

    Non-object passed as first parameter.

### Returns

[](#returns-1)

- `void`

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~1476 days

Total

2

Last Release

1819d ago

PHP version history (2 changes)0.1.0PHP ^7.0

0.1.1PHP ^7.0|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7201812?v=4)[atanvarno](/maintainers/atanvarno)[@Atanvarno](https://github.com/Atanvarno)

---

Top Contributors

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

---

Tags

phpunittestutilityutilities

### Embed Badge

![Health badge](/badges/atanvarno-test-util/health.svg)

```
[![Health](https://phpackages.com/badges/atanvarno-test-util/health.svg)](https://phpackages.com/packages/atanvarno-test-util)
```

###  Alternatives

[ta-tikoma/phpunit-architecture-test

Methods for testing application architecture

10745.9M13](/packages/ta-tikoma-phpunit-architecture-test)[kenjis/ci-phpunit-test

An easier way to use PHPUnit with CodeIgniter 3.x

5861.2M3](/packages/kenjis-ci-phpunit-test)[php-mock/php-mock-phpunit

Mock built-in PHP functions (e.g. time()) with PHPUnit. This package relies on PHP's namespace fallback policy. No further extension is needed.

1718.2M399](/packages/php-mock-php-mock-phpunit)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)[zenstruck/assert

Standalone, lightweight, framework agnostic, test assertion library.

8114.9M8](/packages/zenstruck-assert)[wp-phpunit/wp-phpunit

WordPress core PHPUnit library

803.7M208](/packages/wp-phpunit-wp-phpunit)

PHPackages © 2026

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