aogg/think-phpunit

ThinkPHP6 使用 PHPUnit。

v0.4.2 2024-07-26 08:36 UTC

This package is auto-updated.

Last update: 2024-09-26 08:57:07 UTC


README

ThinkPHP6 使用 PHPUnit
ThinkPHP6 使用 PHPUnit

介绍

  1. phpunit可以为 PHPStorm 指定 PHPUnit 的路径
  2. 可以通过 php think unit 执行命令
  3. BaseTestCase是测试基类,继承 PHPUnit 的测试基类,并提供 ThinkPHP6 专用方法
  4. 继承 \aogg\phpunit\think\BaseTestCase 基类
  5. 支持项目软连接情况下运行单元测试

安装

composer require aogg/think-phpunit:^v0.3

详细

BaseTestCase

支持测试类中调用控制器的方法

    /**
     * 商品列表
     *
     * @return array|mixed
     */
    public function testStoreVerifyFinishList()
    {
        $data = $this->get($this->getRequestUrlString('product/list', ['limit' => 1]));

        return $data;
    }

配置 PHPStorm 的 PHPUnit

配置PHPStorm的PHPUnit

代码示例

配置 PHPStorm 的远程 PHPUnit

image 选择指定目录 /vendor/aogg/think-phpunit/src/phpunit image

本地调试 composer 类库

{

  "repositories": [

    {
      "type": "path",

      "url": "/app/origin/my/github/composer-PHPUnit-ThinkPHP"

    }

  ]
}
composer require aogg/think-phpunit:dev-master