wsteel / tp51unit
thinkphp5.1 简单的单元测试
v0.0.3
2019-07-06 09:59 UTC
This package is auto-updated.
Last update: 2024-09-24 12:44:37 UTC
README
使用 phpstorm 2019 测试 thinkphp5.1 应用的逻辑
用法
composer require wsteel/php51unit
需求
"php": ">=7.0.0",
"topthink/framework": "5.1.*"
"phpunit/phpunit": "6.*"
phpstorm 设置
文件 | 设置 | 语言和框架 | PHP | 测试框架
PHPUnit library -> Path to phpunit.phar -> _YOUR_phpunit-*.phar
Test Runner -> Default bootstrap file: __YOUR_APP__\vendor\wsteel\tp51unit\src\wsteel\tp51unit\TestCase.php
示例
文件名
tests/demo/demoTest.php
内容
namespace tests\demo; use wsteel\tp51unit\TestCase; class demoTest extends TestCase { public function testTrue() { $this->assertTrue(true); } public function testFalse() { $this->assertFalse(false, 'false'); } public function testModel() { $e = \app\serverapi\model\Users::get(1)->toArray(); $this->assertNotEmpty($e); } public function testM() { $user = model('users', 'serverapi\model'); $e = $user->where('id', 1)->find()->toArray(); $this->assertNotEmpty($e); } public function testDB() { $user = \think\Db::name('server_user'); $e = $user->where('id', 1)->find(); $this->assertNotEmpty($e); } public function testConfig() { $config = config('serverapi'); $this->assertNotEmpty($config); } }