PHPackages                             beotie/lib\_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. beotie/lib\_test

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

beotie/lib\_test
================

This package provide a set of class and traits to be used in test cases

09PHP

Since Feb 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Beotie/beotie-lib-test)[ Packagist](https://packagist.org/packages/beotie/lib_test)[ RSS](/packages/beotie-lib-test/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Beotie/lib\_test
================

[](#beotielib_test)

This library is used by Beotie project as base wrapper for some features. The first objective is to be abble to create tests in traits, rather than test case directly.

Implementing
------------

[](#implementing)

This library come with two traits, so it is enough to use these traits into your tests.

```
class MyTestCase extends TestCase
{
    use Beotie\LibTest\Traits\TestCaseTrait,
        MyFeatureTest;

    protected function getTestedInstance() : string
    {
        return MyAwesomeClass::class;
    }
}

trait MyFeatureTest
{
    use Beotie\LibTest\Traits\TestTrait;

    public function myTest()
    {
        $this->getTestCase()->assertTrue(true);
    }
}
```

The `Beotie\LibTest\Traits\TestCaseTrait` implement a `getTestCase()` method that return the current `TestCase` instance. It's needed to implement the `getTestedInstance()` method in order to be able to use the `Beotie\LibTest\Traits\TestTrait` as it define it abstract.

The `TestTrait` methods
-----------------------

[](#the-testtrait-methods)

### createEmptyInstance

[](#createemptyinstance)

In order to make unit testing with full abstraction, the `TestTrait` offer a `createEmptyInstance()` method that return a new instance of defined tested instance without calling constructor.

```
trait MyFeatureTest
{
    use Beotie\LibTest\Traits\TestTrait;

    public function myTest()
    {
        $instanceToTest = $this->createEmptyInstance();
        $this->getTestCase()->assertTrue($instanceToTest->isEmpty());
    }
}
```

### Property getter and setter

[](#property-getter-and-setter)

The `Beotie\LibTest\Traits\TestTrait` allow you to automatically extract and inject values into instance properties. It will follow the inheritance tree in order to find the property location if it is not hosted directly in the tested class and make it accessible if protected or private.

```
trait MyFeatureTest
{
    use Beotie\LibTest\Traits\TestTrait;

    public function myTest()
    {
        $instanceToTest = $this->createEmptyInstance();
        $this->setValue($instance, 'propertyName', 'valueToInject');
        $this->getTestCase()->assertFalse($instanceToTest->isEmpty());

        $instanceToTest->setPropertyName('otherValue');
        $this->getTestCase()->assertEquals('otherValue', $this->getValue($instance, 'propertyName'));
    }
}
```

### TestCase wrapping

[](#testcase-wrapping)

The `Beotie\LibTest\Traits\TestTrait` forward method invocation to the stored TestCase, so it's possible to directly call the `TestCase` methods inside the `TestTrait`.

```
trait MyFeatureTest
{
    use Beotie\LibTest\Traits\TestTrait;

    public function myTest()
    {
        $instanceToTest = $this->createEmptyInstance();
        $this->setValue($instance, 'propertyName', 'valueToInject');
        $this->assertFalse($instanceToTest->isEmpty());

        $instanceToTest->setPropertyName('otherValue');
        $this->assertEquals('otherValue', $this->getValue($instance, 'propertyName'));
    }
}
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![matthieu88160](https://avatars.githubusercontent.com/u/11874266?v=4)](https://github.com/matthieu88160 "matthieu88160 (2 commits)")

### Embed Badge

![Health badge](/badges/beotie-lib-test/health.svg)

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

###  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)
