3.8.1
This commit is contained in:
77
tests/admin/Api/Index_Test.php
Normal file
77
tests/admin/Api/Index_Test.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* PhalApi_Admin\Api\Index_Test
|
||||
*
|
||||
* 针对 ./src/admin/Api/Index.php Admin\Api\Index 类的PHPUnit单元测试
|
||||
*
|
||||
* @author: dogstar 20200113
|
||||
*/
|
||||
|
||||
namespace tests\Admin\Api;
|
||||
use Admin\Api\Index;
|
||||
use App\Common\TimeUtil;
|
||||
use PhalApi\Helper\TestRunner;
|
||||
|
||||
class PhpUnderControl_AdminApiIndex_Test extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public $adminApiIndex;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->adminApiIndex = new \Admin\Api\Index();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
// 输出本次单元测试所执行的SQL语句
|
||||
// var_dump(\PhalApi\DI()->tracer->getSqls());
|
||||
|
||||
// 输出本次单元测试所涉及的追踪埋点
|
||||
// var_dump(\PhalApi\DI()->tracer->getStack());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ runInSeparateProcess
|
||||
* @group testGetRules
|
||||
*/
|
||||
public function testGetRules()
|
||||
{
|
||||
$rs = $this->adminApiIndex->getRules();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testGetIndexData
|
||||
*/
|
||||
public function testGetIndexData()
|
||||
{
|
||||
$url = 's=Admin.Index.GetIndexData';
|
||||
|
||||
@$rs = TestRunner::go($url);
|
||||
|
||||
$this->assertNotEmpty($rs['systemInfo']);
|
||||
$this->assertGreaterThanOrEqual(0, $rs['requestTime']);
|
||||
$this->assertGreaterThanOrEqual(0, $rs['apiNum']);
|
||||
$this->assertGreaterThanOrEqual(0, $rs['users']);
|
||||
$this->assertGreaterThanOrEqual(0, $rs['files']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testGetDataFlow
|
||||
*/
|
||||
public function testGetDataFlow()
|
||||
{
|
||||
|
||||
$url = "s=Admin.Index.GetDataFlow";
|
||||
|
||||
$rs = TestRunner::go($url);
|
||||
|
||||
$this->assertNotEmpty($rs);
|
||||
|
||||
$this->assertGreaterThanOrEqual(0, $rs[0]['total']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user