bingher/think-test
最新稳定版本:v1.0.2
Composer 安装命令:
composer require bingher/think-test
包简介
PHPUnit for ThinkPHP6
README 文档
README
Install
composer require bingher/think-test
Usage
Add test case /test/Test.php
<?php use bingher\ThinkTest\ThinkTest; class Test extends ThinkTest { public function testTap() { $result = tap('world'); $this->assertEquals($result, 'world'); $result = tap('world', null); $this->assertEquals($result, 'world'); $result = tap( 'world', function ($v) { $v = 'hello ' . $v; } ); $this->assertEquals($result, 'world'); $result = tap( 'world', function (&$v) { $v = 'hello ' . $v; } ); $this->assertEquals($result, 'hello world'); } }
Run test case
win
./vendor/bin/tpt.bat ./test/Test.php
unix
./vendor/bin/tpt ./test/Test.php
More
Wait Test Class test/Hello.php
<?php namespace bingher\test; use bingher\ThinkTest\ThinkTest; class Test extends ThinkTest { public function testTap() { $result = tap('world'); $this->assertEquals($result, 'world'); $result = tap('world', null); $this->assertEquals($result, 'world'); $result = tap( 'world', function ($v) { $v = 'hello ' . $v; } ); $this->assertEquals($result, 'world'); $result = tap( 'world', function (&$v) { $v = 'hello ' . $v; } ); $this->assertEquals($result, 'hello world'); } }
Test Case test/HelloTest.php
<?php namespace bingher\test; use bingher\ThinkTest\ThinkTest; class HelloTest extends ThinkTest { public function testSay() { $hello = new Hello; //use prop function get protected properties $name = $this->prop($hello, 'name'); $this->assertEquals($name, 'bingher'); $result = $hello->say(); $this->assertEquals($result, 'hello bingher'); } public function testSmile() { $hello = new Hello('mondy'); //use prop function get protected properties $name = $this->prop($hello, 'name'); $this->assertEquals($name, 'mondy'); //use call function run protected function $result = $this->call($hello, 'smile'); $this->assertEquals($result, 'hello mondy :)'); //add params $result = $this->call($hello, 'smile', [2]); $this->assertEquals($result, 'hello mondy :):)'); //use prop function set protected properties value $this->prop($hello, 'name', 'everyone'); $name = $this->prop($hello, 'name'); $this->assertEquals($name, 'everyone'); } }
统计信息
- 总下载量: 73
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-30