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

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

aspirantzhang/thinkphp6-unit-test
=================================

A simple tool for unit testing with PHPUnit and ThinkPHP 6

1.1.2(5y ago)17371MITPHP

Since Apr 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/aspirantzhang/thinkphp6-unit-test)[ Packagist](https://packagist.org/packages/aspirantzhang/thinkphp6-unit-test)[ RSS](/packages/aspirantzhang-thinkphp6-unit-test/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (5)Dependencies (3)Versions (6)Used By (0)

ThinkPHP6 Unit Test
===================

[](#thinkphp6-unit-test)

A simple tool for unit testing with PHPUnit and ThinkPHP 6

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

[](#requirements)

- [Thinkphp v6.0+](https://github.com/top-think/framework)
- [PHPUnit v9.x+](https://github.com/sebastianbergmann/phpunit)
- [Mockery v1.x+](https://github.com/mockery/mockery)

Install
-------

[](#install)

```
composer require aspirantzhang/thinkphp6-unit-test --dev

```

Usage
-----

[](#usage)

First, use the `UnitTestTrait` in your class

```
use aspirantzhang\thinkphp6UnitTest\UnitTestTrait;

```

When testing a class (such as a controller), use it before your statement, and set `$this->app` as the parameter of the controller, like this

```
$this->startRequest();
$yourController = new YourController($this->app);

```

or simply a function test

```
$this->startApp();

```

A full method test might be

```
public function testAdminHome()
{
    $this->startRequest();
    $adminController = new AdminController($this->app);
    $response = $adminController->home();

    $this->assertEquals(200, $response->getCode());
}

```

More supported usage

```
// get with no param
$this->startRequest();
// get with param
$this->startRequest('GET', ['trash' => 'onlyTrashed']);
// post with data
$this->startRequest('POST', ['type' => 'delete', 'ids' => [1]]);
// put with data
$this->startRequest('PUT', ['display_name' => 'Admin']);
// mock localization
$this->mockLang('zh-cn');
// close mock localization
$this->endMockLang();

```

Finally, close the request.

```
$this->endRequest();

```

You can refer to the project using this package

License
-------

[](#license)

MIT

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

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

Total

5

Last Release

1832d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06e113a1e04f4cde069f333882f90653a22ce080afa4ac21d1c3d95533b074d5?d=identicon)[aspirantzhang](/maintainers/aspirantzhang)

---

Top Contributors

[![aspirantzhang](https://avatars.githubusercontent.com/u/24559988?v=4)](https://github.com/aspirantzhang "aspirantzhang (11 commits)")

---

Tags

phpunitthinkphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[topthink/think-testing

4295.6k8](/packages/topthink-think-testing)[zoujingli/think-library

Core library and common services for ThinkAdmin

8373.4k20](/packages/zoujingli-think-library)[ichynul/tpextmyadmin

thinkphp extension

141.6k](/packages/ichynul-tpextmyadmin)

PHPackages © 2026

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