PHPackages                             alexrili/lumen-test-booster - 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. alexrili/lumen-test-booster

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

alexrili/lumen-test-booster
===========================

just a small boost of lumen tests

v1.0.2(6y ago)335.4kMITPHPCI failing

Since Sep 24Pushed 6y ago1 watchersCompare

[ Source](https://github.com/alexrili/lumen-test-booster)[ Packagist](https://packagist.org/packages/alexrili/lumen-test-booster)[ Docs](https://github.com/alexrili/lumen-test-booster.git)[ RSS](/packages/alexrili-lumen-test-booster/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Lumen Test Booster
==================

[](#lumen-test-booster)

Just a small abstraction of lumen test with aspectmock and handler excpetion.

Install
-------

[](#install)

```
# Install in dev mode
composer require alexrili/lumen-test-booster --dev
```

how to use
----------

[](#how-to-use)

First of all, you need to make sure you have the `Stubs` folder inside your high level `test` folder. Name your `clone classes` as YourClassName**Stub** and put them inside a `Stubs` folder

```
    tests\
        Stubs\
          ClassYouWantToCloneStub

```

Import LumenTestBooster as a `trait` in your high level TestCase class.

> use \\LumenTestBooster;

```
// ...
abstract class TestCase extends Base
{
    use \LumenTestBooster;
//    ...
}
```

### How to clone/mock your tests

[](#how-to-clonemock-your-tests)

Just ovewriter the `setUp` method and call `$this->stubClasses()` method to stub/mock your classes

> Make sure you have, a `Stubs` folder inside your `test` high level folder.

```
//  ...
    public function setUp(): void
    {
        $this->stubClasses([ClassYourWantToMock::class]);
        parent::setUp();
    }
//    ...
```

### Use case

[](#use-case)

**1st case scenario.**Let's say you have a class name **NotificationService** and you want to mock/stub this class. First of all you need to create a **NotificationServiceStub** inside a `tests/Stubs/` folder. After this, you just call `$this->stubClasses([ClassYourWantToMock::class]);` inside your `setUp` method. And That's It.

> Don't forget to import `LumenTestBooster` in your `TestCase` class.

```
    tests\
        Stubs\
          NotificationServiceStub.php

```

```
//  ...
    public function setUp(): void
    {
        $this->stubClasses([NotificationService::class]);
        parent::setUp();
    }
//    ...
```

**2st case scenario.**But, if you want to test some different returns of a method? Eg. you need to test a error return.

```
    tests\
        Stubs\
          NotificationServiceStub.php

```

> Inside your StubClass(in this case NotificationServiceStub), you will create a `sendEmailNotificationError()` method. In this case you can disable exception handler by call `$this->withoutShowingExceptions()`

```
//  ...
    /** @test */
    public function should_return_erro_when_consumer_doesnt_have_an_email()
    {
      $this->doubleMethod(NotificationService::class, 'sendEmailNotification')
                  ->setReturn(NotificationServiceStub::class, "sendEmailNotificationError");
    }
//    ...
```

Other configs
-------------

[](#other-configs)

You can change exception handlers to not showing/handler in runtime. Say you have a specific test you want to return an error.

```
//  ...
    /** @test */
    public function should_return_error()
    {
        $this->withoutShowingExceptions();
//     ...
    }
//    ...
```

You also can change the default set of stub paths.

> This config must be put inside you high level test case class.

```
//  ...
    /**
     * setup before class function
     *
     * @return void
     */
    public static function setUpBeforeClass(): void
    {

        self::initAspectMock(
        [
             'appDir' => '/', // root directory of your aplication.
             'debug' => true, // to get debug details
             'includePaths' => [__DIR__ . '/api/app', '/common'], // you can put how many folders you want to be maped here.
             'cacheDir' => __DIR__ . '../storage/cache/__tests_ // place where you 'mocked/stub' class are runing.
        ]);
        parent::setUpBeforeClass();
    }
//    ...
```

### Thanks!

[](#thanks)

@GMBN (the goldenboy) @cadukiz

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

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

Total

4

Last Release

2387d ago

Major Versions

v0.1.1-beta → v1.0.02019-09-25

### Community

Maintainers

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

---

Top Contributors

[![alexrili](https://avatars.githubusercontent.com/u/1238430?v=4)](https://github.com/alexrili "alexrili (14 commits)")

---

Tags

phpunittestlaravelmocklumen

### Embed Badge

![Health badge](/badges/alexrili-lumen-test-booster/health.svg)

```
[![Health](https://phpackages.com/badges/alexrili-lumen-test-booster/health.svg)](https://phpackages.com/packages/alexrili-lumen-test-booster)
```

###  Alternatives

[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)[colinodell/psr-testlogger

PSR-3 compliant test logger based on psr/log v1's, but compatible with v2 and v3 too!

1712.1M47](/packages/colinodell-psr-testlogger)[albertcht/lumen-testing

Testing Suite For Lumen like Laravel does.

4335.5k1](/packages/albertcht-lumen-testing)[icecave/isolator

Dependency injection for global functions.

371.3M29](/packages/icecave-isolator)[elliotchance/concise

Concise is test framework for using plain English and minimal code, built on PHPUnit.

45223.8k4](/packages/elliotchance-concise)[zizaco/testcases-laravel

Some classes to help write tests for laravel 4 applications

4650.5k2](/packages/zizaco-testcases-laravel)

PHPackages © 2026

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