3.8.1
This commit is contained in:
61
tests/admin/Api/IP_Test.php
Normal file
61
tests/admin/Api/IP_Test.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* PhalApi_App\Api\IP_Test
|
||||
*
|
||||
* 针对 ../src/app/Api/IP.php App\Api\IP 类的PHPUnit单元测试
|
||||
*
|
||||
* @author: dogstar 20200106
|
||||
*/
|
||||
|
||||
namespace tests\Admin\Api;
|
||||
use Admin\Api\IP;
|
||||
use PhalApi\Helper\TestRunner;
|
||||
|
||||
class PhpUnderControl_AppApiIP_Test extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public $appApiIP;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->appApiIP = new \Admin\Api\IP();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
// 输出本次单元测试所执行的SQL语句
|
||||
// var_dump(\PhalApi\DI()->tracer->getSqls());
|
||||
|
||||
// 输出本次单元测试所涉及的追踪埋点
|
||||
// var_dump(\PhalApi\DI()->tracer->getStack());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group testGetRules
|
||||
*/
|
||||
public function testGetRules()
|
||||
{
|
||||
$rs = $this->appApiIP->getRules();
|
||||
$this->assertTrue(is_array($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testGetInfo
|
||||
*/
|
||||
public function testGetInfo()
|
||||
{
|
||||
//Step 1. 构建请求URL
|
||||
$url = 'service=Admin.IP.GetInfo&ip=61.147.110.191';
|
||||
|
||||
//Step 2. 执行请求
|
||||
$rs = TestRunner::go($url);
|
||||
|
||||
//Step 3. 验证
|
||||
$this->assertNotEmpty($rs);
|
||||
$this->assertNotEmpty($rs['info']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user