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(4y ago)07151MITPHP

Since Apr 15Pushed 4y 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 6d 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

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

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

1784d 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

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[pdepend/pdepend

Official version of pdepend to be handled with Composer

954110.9M815](/packages/pdepend-pdepend)[instaclick/php-webdriver

PHP WebDriver for Selenium 2

43761.8M22](/packages/instaclick-php-webdriver)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69417.9M510](/packages/spatie-phpunit-snapshot-assertions)[szepeviktor/phpstan-wordpress

WordPress extensions for PHPStan

3257.8M898](/packages/szepeviktor-phpstan-wordpress)

PHPackages © 2026

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