wsteel / tp60unit
一个简单的 thinkphp6.0 单元测试
v0.0.2
2020-03-24 02:45 UTC
This package is auto-updated.
Last update: 2024-09-24 14:01:05 UTC
README
使用 phpstorm 2020 测试 thinkphp6.0 应用逻辑
用法
composer require wsteel/php60unit
require
"php": ">=7.2.0",
"topthink/framework": "6.0.*"
"phpunit/phpunit": "8.*"
phpstorm 设置
文件 | 设置 | 语言和框架 | PHP | 测试框架
PHPUnit library -> Path to phpunit.phar -> _YOUR_phpunit-*.phar
Test Runner -> Default bootstrap file: __YOUR_APP__\vendor\autoload.php
示例
文件名
tests/demo/demoTest.php
内容
namespace tests\demo; use wsteel\tp60unit\TestCase; class demoTest extends TestCase { public function testTrue() { $this->assertTrue(true); } public function testFalse() { $this->assertFalse(false, 'false'); } public function testModel() { $e = \app\model\User::find(1); dump($e); $this->assertNotEmpty($e); } public function testDB() { $user = Db::name('user'); $e = $user->where('id', '=' ,1)->select(); dump($e); $this->assertNotEmpty($e); } public function testConfig() { $config = config('database'); dump($config); $this->assertNotEmpty($config); } }