PHPackages                             fabstract/unit-test - 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. fabstract/unit-test

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

fabstract/unit-test
===================

Unit test library on top of PHP Unit

v1.0.1(7y ago)0258MITPHPPHP ^7.1

Since Sep 14Pushed 7y ago2 watchersCompare

[ Source](https://github.com/Fabstract/UnitTest)[ Packagist](https://packagist.org/packages/fabstract/unit-test)[ RSS](/packages/fabstract-unit-test/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

[![](https://avatars3.githubusercontent.com/u/36798053?s=200&v=4)](https://avatars3.githubusercontent.com/u/36798053?s=200&v=4)

 [![Total Downloads](https://camo.githubusercontent.com/8837772b227417a6be42b93f61a93528e93731e1b273517909ed717237ed71cf/68747470733a2f2f706f7365722e707567782e6f72672f6661627374726163742f756e69742d746573742f642f746f74616c2e737667)](https://packagist.org/packages/fabstract/unit-test) [![Latest Stable Version](https://camo.githubusercontent.com/12aca0d80f3280d735be1e816077f7c626e2f87a8a9202cf50cad1d9aab24843/68747470733a2f2f706f7365722e707567782e6f72672f6661627374726163742f756e69742d746573742f762f737461626c652e737667)](https://packagist.org/packages/fabstract/unit-test) [![License](https://camo.githubusercontent.com/43bc684f03a3de1232913059d9fad6c2ae6e34becd56b9c6695cf9196015e08c/68747470733a2f2f706f7365722e707567782e6f72672f6661627374726163742f756e69742d746573742f6c6963656e73652e737667)](https://packagist.org/packages/fabstract/unit-test)

UnitTest
--------

[](#unittest)

Unit test library on top of PHP Unit.

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

[](#installation)

**Note:** PHP 7.1 or higher is required.

1. Install [composer](https://getcomposer.org/download/).
2. Run `composer require fabstract/unit-test`.

Usage
-----

[](#usage)

### MethodTestBase

[](#methodtestbase)

This class is used for separating unit tests by which methods they were written for. Suppose you have the following class:

```

    namespace MyPackage;

    class Calculator
    {
        public function add($a, $b) {
            return $a + $b;
        }

        public function multiply($a, $b) {
            return $a * $b;
        }
    }
```

Now in order to write tests for these two methods:

- Create a directory, preferably the same name with the class name.
- Inside that directory, create a class for each method you want to test.
- Name the class as `methodName` + `MethodTest`. For example `AddMethodTest`.
- Extend the class from `MethodTestBase`.

**Note:** Your method should be camelcase.

Here is what it looks like:

```
    namespace MyPackage\Calculator;

    class AddMethodTest extends \Fabstract\Component\UnitTest\MethodTestBase
    {
        public function testOneAndOneEqualsTwo() {
            $arguments = [1, 1];

            $result = $this->call(new Calculator(), $arguments);

            $this->assertEquals(2, $result);
        }

        public function testOneAndZeroEqualsOne() {
            $arguments = [1, 0];

            $result = $this->call(new Calculator(), $arguments);

            $this->assertEquals(1, $result);
        }
    }
```

and

```
    namespace MyPackage\Calculator;

    class MultiplyMethodTest extends \Fabstract\Component\UnitTest\MethodTestBase
    {
        public function testOneAndOneEqualsOne() {
            $arguments = [1, 1];

            $result = $this->call(new Calculator(), $arguments);

            $this->assertEquals(1, $result);
        }

        public function testOneAndZeroEqualsZero() {
            $arguments = [1, 0];

            $result = $this->call(new Calculator(), $arguments);

            $this->assertEquals(0, $result);
        }
    }
```

You can add as many unit tests as you want, without worrying about a method's tests getting mixed up with other method's tests.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Total

2

Last Release

2796d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11666659?v=4)[Ahmet Türk](/maintainers/fabsolute)[@Fabsolute](https://github.com/Fabsolute)

![](https://www.gravatar.com/avatar/6f4080b0f9e4fa14a66343b0c230ca6fe46a1e326941ce2a98359501309b2406?d=identicon)[necipallef](/maintainers/necipallef)

---

Top Contributors

[![necipallef](https://avatars.githubusercontent.com/u/11958773?v=4)](https://github.com/necipallef "necipallef (7 commits)")

---

Tags

phptestunit test

### Embed Badge

![Health badge](/badges/fabstract-unit-test/health.svg)

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

###  Alternatives

[letsdrink/ouzo-goodies

Utility classes, test assertions and mocking framework extracted from Ouzo framework.

132617.9k7](/packages/letsdrink-ouzo-goodies)[quizlet/hammock

Hammock is a stand-alone mocking library for Hacklang.

27445.5k](/packages/quizlet-hammock)[hot/phpunit-runner

The lib allows to watch phpunit tests

3066.9k4](/packages/hot-phpunit-runner)[robiningelbrecht/phpunit-coverage-tools

PHPUnit coverage tools

1783.0k34](/packages/robiningelbrecht-phpunit-coverage-tools)[yegor256/phprack

Light framework for automation of integration tests

254.7k](/packages/yegor256-phprack)

PHPackages © 2026

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