This commit is contained in:
2022-03-21 11:16:38 +08:00
commit e89e807c64
1040 changed files with 284164 additions and 0 deletions

View File

@@ -0,0 +1,133 @@
<?php
/**
* PhalApi_Admin\Api\Apps_Test
*
* 针对 ../src/admin/Api/Apps.php Admin\Api\Apps 类的PHPUnit单元测试
*
* @author: dogstar 20200112
*/
namespace tests\Admin\Api;
use Admin\Api\Apps;
use Base\Domain\Apps as AppsDomain;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AdminApiApps_Test extends \PHPUnit\Framework\TestCase
{
public $adminApiApps;
protected function setUp()
{
parent::setUp();
$this->adminApiApps = new \Admin\Api\Apps();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->adminApiApps->getRules();
$this->assertTrue(is_array($rs));
}
/**
* @group testGetAppList
*/
public function testGetAppList()
{
$domain = new AppsDomain();
$domain->addApp('appName_testGetAppList', 'appKey_testGetAppList', 'appSecret_123');
$url = 's=Admin.Apps.GetAppList';
$rs = TestRunner::go($url);
$this->assertNotEmpty($rs['list']);
}
/**
* @group testGetAppSecret
*/
public function testGetAppSecret()
{
$domain = new AppsDomain();
$id = $domain->addApp('appName_testGetAppSecret', 'testGetAppSecret', '123');
$url = 's=Admin.Apps.GetAppSecret&id='.$id;
$rs = TestRunner::go($url);
$this->assertEquals('123', $rs['app_secret']);
}
/**
* @group testAlterAppStat
*/
public function testAlterAppStat()
{
$domain = new AppsDomain();
$id = $domain->addApp('appName_testAlterAppStat', 'testAlterAppStat', '888');
$url = 's=Admin.Apps.AlterAppStat&type=0&id=' . $id;
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_success']);
$url = 's=Admin.Apps.AlterAppStat&type=1&id=' . $id;
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_success']);
}
/**
* @group testAddApp
*/
public function testAddApp()
{
$url = 's=Admin.Apps.AddApp&app_key=testAddApp&app_secret=xxx&appName=testAddApp';
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_add']);
}
/**
* @group testCreateAppSecret
*/
public function testCreateAppSecret()
{
$url = 's=Admin.Apps.CreateAppSecret';
$rs = TestRunner::go($url);
$this->assertNotEmpty($rs['appSecret']);
$this->assertTrue(is_string($rs['appSecret']));
$this->assertEquals(32, strlen($rs['appSecret']));
}
/**
* @group testEditApp
*/
public function testEditApp(){
$domain = new AppsDomain();
$id = $domain->addApp('phpunit', 'phpunit', 'phpunit');
$url = "s=Admin.Apps.EditApp&id={$id}&app_name=testEditApp&app_secret=testEditApp";
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_update']);
$rs = $domain->getAppById($id);
$this->assertEquals('testEditApp', $rs['app_name']);
$this->assertEquals('testEditApp', $rs['app_secret']);
}
}

View File

@@ -0,0 +1,119 @@
<?php
/**
* PhalApi_App\Api\Config_Test
*
* 针对 ../src/app/Api/Config.php App\Api\Config 类的PHPUnit单元测试
*
* @author: dogstar 20191219
*/
namespace tests\Admin\Api;
use Admin\Api\Config;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AppApiConfig_Test extends \PHPUnit\Framework\TestCase
{
public $appApiConfig;
protected function setUp()
{
parent::setUp();
$this->appApiConfig = new \Admin\Api\Config();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->appApiConfig->getRules();
$this->assertTrue(is_array($rs));
}
/**
* @group testAddConfig
*/
public function testAddConfig()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Config.AddConfig&config_name=phpunit_test&config_value=2019&username=dogstar&sign=B83F9015965B68185E97792EC40FC55D&app_key=CEE4B8A091578B252AC4C92FB4E893C3';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertEquals(true, $rs['is_add']);
}
/**
* @group testGetConfig
*/
public function testGetConfig()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Config.GetConfig&config_name=phpunit_test&config_value=2019&username=dogstar&sign=B83F9015965B68185E97792EC40FC55D&app_key=CEE4B8A091578B252AC4C92FB4E893C3';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertEquals('2019', $rs['config_value']);
}
public function testGetConfigNotExists()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Config.GetConfig&config_name=phpunit_test_404&config_value=2019&username=dogstar&sign=B83F9015965B68185E97792EC40FC55D&app_key=CEE4B8A091578B252AC4C92FB4E893C3';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertSame(null, $rs['config_value']);
}
/**
* @group testEditConfig
*/
public function testEditConfig()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Config.EditConfig&config_name=phpunit_test&config_value=2020&username=dogstar&sign=B83F9015965B68185E97792EC40FC55D&app_key=CEE4B8A091578B252AC4C92FB4E893C3';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertEquals(true, $rs['is_edit']);
$url = 'service=Admin.Config.GetConfig&config_name=phpunit_test&config_value=2019&username=dogstar&sign=B83F9015965B68185E97792EC40FC55D&app_key=CEE4B8A091578B252AC4C92FB4E893C3';
$rs = TestRunner::go($url);
$this->assertEquals('2020', $rs['config_value']);
}
/**
* @group testRemoveConfig
*/
public function testRemoveConfig()
{
$url = 'service=Admin.Config.RemoveConfig&config_name=phpunit_test&config_value=2019&username=dogstar&sign=B83F9015965B68185E97792EC40FC55D&app_key=CEE4B8A091578B252AC4C92FB4E893C3';
$rs = TestRunner::go($url);
$this->assertEquals(true, $rs['is_remove']);
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* PhalApi_Admin\Api\File_Test
*
* 针对 ./src/admin/Api/File.php Admin\Api\File 类的PHPUnit单元测试
*
* @author: dogstar 20200113
*/
namespace tests\Admin\Api;
use Admin\Api\File;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AdminApiFile_Test extends \PHPUnit\Framework\TestCase
{
public $adminApiFile;
protected function setUp()
{
parent::setUp();
$this->adminApiFile = new \Admin\Api\File();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->adminApiFile->getRules();
}
/**
* @group testGetList
*/
public function testGetList()
{
// 提供一些数据
$domain = new \Base\Domain\File();
$domain->addUploadFile('x.jpg', 'jpg', 10, '/uploads/haha.png', 'http://localhost/uploads/haha.png');
$url = "service=Admin.File.GetList";
$rs = TestRunner::go($url);
$this->assertNotEmpty($rs);
$this->assertNotEmpty($rs['total']);
$this->assertNotEmpty($rs['files']);
}
/**
* @group testDelFile
*/
public function testDelFile()
{
// 提供一些数据
$domain = new \Base\Domain\File();
$id = $domain->addUploadFile('x.jpg', 'jpg', 10, '/uploads/haha.png', 'http://localhost/uploads/haha.png');
$url = "service=Admin.File.DelFile&id=$id";
$rs = TestRunner::go($url);
$this->assertTrue(is_bool($rs));
$this->assertTrue($rs);
}
}

View 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']);
}
}

View 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']);
}
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* PhalApi_App\Api\Pinyin_Test
*
* 针对 ./src/app/Api/Pinyin.php App\Api\Pinyin 类的PHPUnit单元测试
*
* @author: dogstar 20200107
*/
namespace tests\Admin\Api;
use Admin\Api\Pinyin;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AppApiPinyin_Test extends \PHPUnit\Framework\TestCase
{
public $appApiPinyin;
protected function setUp()
{
parent::setUp();
$this->appApiPinyin = new \Admin\Api\Pinyin();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->appApiPinyin->getRules();
$this->assertTrue(is_array($rs));
}
/**
* @group testConvert
*/
public function testConvert()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Pinyin.Convert&text=你好';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertNotEmpty($rs['pinyin']);
$this->assertEquals($rs['pinyin'], "ni hao");
}
/**
* @group testAbbr
*/
public function testAbbr()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Pinyin.Abbr&text=你好';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertNotEmpty($rs['pinyin']);
$this->assertEquals($rs['pinyin'], "n h");
}
/**
* @group testSentence
*/
public function testSentence()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Pinyin.Sentence&text=你好!';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertNotEmpty($rs['pinyin']);
$this->assertEquals($rs['pinyin'], "ni hao!");
}
/**
* @group testName
*/
public function testName()
{
//Step 1. 构建请求URL
$url = 'service=Admin.Pinyin.Name&text=单田芳!';
//Step 2. 执行请求
$rs = TestRunner::go($url);
//Step 3. 验证
$this->assertNotEmpty($rs);
$this->assertNotEmpty($rs['pinyin']);
$this->assertEquals($rs['pinyin'], "shan tian fang");
}
}

View File

@@ -0,0 +1,57 @@
<?php
/**
* PhalApi_Admin\Api\Requests_Test
*
* 针对 ../src/admin/Api/Requests.php Admin\Api\Requests 类的PHPUnit单元测试
*
* @author: dogstar 20200116
*/
namespace tests\Admin\Api;
use Admin\Api\Requests;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AdminApiRequests_Test extends \PHPUnit\Framework\TestCase
{
public $adminApiRequests;
protected function setUp()
{
parent::setUp();
$this->adminApiRequests = new \Admin\Api\Requests();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->adminApiRequests->getRules();
$this->assertTrue(is_array($rs));
}
/**
* @group testGetLogList
*/
public function testGetLogList()
{
$url = 's=Admin.Requests.GetLogList';
$rs = TestRunner::go($url);
$this->assertArrayHasKey('total', $rs);
$this->assertArrayHasKey('items', $rs);
}
}

View File

@@ -0,0 +1,214 @@
<?php
/**
* PhalApi_Admin\Api\Rights_Test
*
* 针对 ./src/admin/Api/Rights.php Admin\Api\Rights 类的PHPUnit单元测试
*
* @author: dogstar 20200113
*/
namespace tests\Admin\Api;
use Admin\Api\Rights;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AdminApiRights_Test extends \PHPUnit\Framework\TestCase
{
public $adminApiRights;
protected function setUp()
{
parent::setUp();
$this->adminApiRights = new \Admin\Api\Rights();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->adminApiRights->getRules();
}
/**
* @group testGetAllAppApis
*/
public function testGetAllAppApis()
{
$url = "s=Admin.Rights.GetAllAppApis";
@$rs = TestRunner::go($url);
$this->assertNotEmpty($rs);
$this->assertGreaterThanOrEqual(0, $rs['total']);
}
/**
* @group testAssignRights
*/
public function testAssignRights()
{
$url = "s=Admin.Rights.AssignRights&appKey=123&assign_service=App.Site.Index";
$rs = TestRunner::go($url);
$this->assertEquals($rs, array('service' => array("App.Site.Index")));
}
/**
* @group testRemoveRights
*/
public function testRemoveRights()
{
$domain = new \Base\Domain\Rights();
$domain->assignRights('123', 'App.Site.Index');
$url = "s=Admin.Rights.RemoveRights&remove_service=App.Site.Index";
$rs = TestRunner::go($url);
$this->assertEquals($rs, array('service' => array("App.Site.Index")));
}
public function testaddRightsService()
{
$url = "s=Admin.Rights.addRightsService&service_desc=xxx&rights_service=Mine.Site.Index";
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_add']);
$rs = TestRunner::go($url);
$this->assertFalse($rs['is_add']);
}
public function testRemoveRightsService()
{
$url = "s=Admin.Rights.RemoveRightsService&service_desc=xxx&rights_service=Mine.Site.Index";
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_remove']);
}
public function testListAllRightsService()
{
$url = "s=Admin.Rights.addRightsService&service_desc=xxx&rights_service=Mine.Site.Index222";
$rs = TestRunner::go($url);
$url = "s=Admin.Rights.addRightsService&service_desc=xxx&rights_service=Mine.Site.Index333";
$rs = TestRunner::go($url);
$url = "s=Admin.Rights.ListAllRightsService";
$rs = TestRunner::go($url);
// var_dump($rs);
$this->assertNotEmpty($rs['items']);
}
public function testassignRightsForDevTypeOrNot() {
$url = "s=Admin.Rights.assignRightsForDevTypeOrNot&rights_service=Mine.Site.Index222&member_type=100";
$rs = TestRunner::go($url);
// var_dump($rs);
$this->assertTrue($rs['is_allow']);
$url = "s=Admin.Rights.assignRightsForDevTypeOrNot&rights_service=Mine.Site.Index222&member_type=100";
$rs = TestRunner::go($url);
// var_dump($rs);
$this->assertFalse($rs['is_allow']);
}
public function testListAllRightsForDeveloperType()
{
$url = "s=Admin.Rights.ListAllRightsForDeveloperType";
$rs = TestRunner::go($url);
// var_dump($rs);
$this->assertNotEmpty($rs['items']);
$this->assertNotEmpty($rs['dev_types']);
}
public function testsearchRightsList()
{
$url = "s=Admin.Rights.searchRightsList&member_type=100&user_id=9";
$rs = TestRunner::go($url);
// var_dump($rs);
//$this->assertNotEmpty($rs['items']);
$this->assertNotEmpty($rs['dev_types']);
$url = "s=Admin.Rights.searchRightsList";
$rs = TestRunner::go($url);
// var_dump($rs);
$this->assertNotEmpty($rs['items']);
$this->assertNotEmpty($rs['dev_types']);
}
public function testassignRightsOrNot()
{
$url = "s=Admin.Rights.assignRightsOrNot&id=1";
$rs = TestRunner::go($url);
$this->assertTrue(true);
}
public function testcreateNewRightsRuleRepeat() {
$url = "s=Admin.Rights.createNewRightsRule&rights_service=App.xx.yy&member_type=100&is_allow=1";
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_add']);
}
/**
* @expectedException PhalApi\Exception\BadRequestException
*/
public function testcreateNewRightsRule() {
$url = "s=Admin.Rights.createNewRightsRule&rights_service=App.xx.yy&member_type=100&is_allow=1";
$rs = TestRunner::go($url);
}
/**
* @expectedException PhalApi\Exception\BadRequestException
*/
public function testgetDevAppApis()
{
$url = "s=Admin.Rights.getDevAppApis&app_key=123";
$rs = TestRunner::go($url);
$this->assertTrue(true);
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* PhalApi_Admin\Api\Task_Test
*
* 针对 ./src/admin/Api/Task.php Admin\Api\Task 类的PHPUnit单元测试
*
* @author: dogstar 20200113
*/
namespace tests\Admin\Api;
use Admin\Api\Task;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AdminApiTask_Test extends \PHPUnit\Framework\TestCase
{
public $adminApiTask;
protected function setUp()
{
parent::setUp();
$this->adminApiTask = new \Admin\Api\Task();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testAddTaskConfig
*/
public function testAddTaskConfig()
{
$url = "s=Admin.Task.AddTaskConfig&title=test&task_service=App.Site.Index";
$rs = TestRunner::go($url);
$this->assertTrue(is_int($rs['id']));
$this->assertGreaterThanOrEqual(0, $rs['id']);
}
}

View File

@@ -0,0 +1,199 @@
<?php
/**
* PhalApi_Admin\Api\User_Test
*
* 针对 ../src/admin/Api/User.php Admin\Api\User 类的PHPUnit单元测试
*
* @author: dogstar 20200112
*/
namespace tests\Admin\Api;
use Admin\Api\User;
use PhalApi\Helper\TestRunner;
class PhpUnderControl_AdminApiUser_Test extends \PHPUnit\Framework\TestCase
{
public $adminApiUser;
protected function setUp()
{
parent::setUp();
$this->adminApiUser = new \Admin\Api\User();
}
protected function tearDown()
{
// 输出本次单元测试所执行的SQL语句
// var_dump(\PhalApi\DI()->tracer->getSqls());
// 输出本次单元测试所涉及的追踪埋点
// var_dump(\PhalApi\DI()->tracer->getStack());
}
/**
* @group testGetRules
*/
public function testGetRules()
{
$rs = $this->adminApiUser->getRules();
$this->assertTrue(is_array($rs));
}
/**
* @group testGetAllMembers
*/
public function testGetAllMembers()
{
$url = 's=Admin.User.AddMember&username=testGetAllMembers&password=123456&member_type=0';
$rs = TestRunner::go($url);
$url = 's=Admin.User.GetAllMembers';
$rs = TestRunner::go($url);
$this->assertNotEmpty($rs['list']);
}
/**
* @group testDelMember
*/
public function testDelMemberOK()
{
$url = 's=Admin.User.AddMember&username=testDelMemberOK&password=123456&member_type=0';
$rs = TestRunner::go($url);
$url = 's=Admin.User.DelMember&id=2';
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_success']);
}
/**
* @group testDelMember
*/
public function testDelMember()
{
$url = 's=Admin.User.DelMember&id=100';
$rs = TestRunner::go($url);
$this->assertFalse($rs['is_success']);
}
public function testGetMember()
{
$url = 's=Admin.User.GetMember&id=1';
$rs = TestRunner::go($url);
$this->assertEquals(1, $rs['member']['id']);
}
/**
* @depends testDelMember
*/
public function testGetMemberNo()
{
$url = 's=Admin.User.GetMember&id=2';
$rs = TestRunner::go($url);
// var_dump($rs);
$this->assertEmpty($rs['member']);
}
public function testEditMember() {
$url = 's=Admin.User.AddMember&username=testEditMember&password=123456&member_type=0';
$rs = TestRunner::go($url);
$uid = $rs['uid'];
// 修改信息和密码
$url = 's=Admin.User.EditMember&sex=1&email=xx@api.com&password=654321&id=' . $uid;
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_update']);
$this->assertTrue($rs['is_alter_password']);
}
/**
* @expectedException PhalApi\Exception\BadRequestException
*/
public function testEditAdminMember() {
$url = 's=Admin.User.AddMember&username=testEditAdminMember&password=123456&member_type=200';
$rs = TestRunner::go($url);
$uid = $rs['uid'];
// 修改信息和密码
$url = 's=Admin.User.EditMember&sex=1&email=xx@api.com&password=654321&id=' . $uid;
$rs = TestRunner::go($url);
}
/**
* @group testAddMember
*/
public function testAddMember()
{
$url = 's=Admin.User.AddMember&username=testAddMember&password=123456&member_type=0';
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_add']);
$this->assertGreaterThan(0, $rs['uid']);
}
/**
* @group testGetDataFlow
*/
public function testGetDataFlow()
{
$url = 's=Admin.User.GetDataFlow';
$rs = TestRunner::go($url);
$this->assertArrayHasKey('list', $rs);
}
/**
* @group testGetLoginStatistics
*/
public function testGetLoginStatistics()
{
$url = 's=Admin.User.GetLoginStatistics';
$rs = TestRunner::go($url);
$this->assertArrayHasKey('list', $rs);
}
/**
* @group testAlterMemberStatus
*/
public function testAlterMemberStatus()
{
$url = 's=Admin.User.AddMember&username=testAlterMemberStatus&password=123456&member_type=0';
$rs = TestRunner::go($url);
$uid = $rs['uid'];
$url = 's=Admin.User.AlterMemberStatus&type=0&id=' . $uid;
$rs = TestRunner::go($url);
$this->assertTrue($rs['is_success']);
}
public function testGetLastestLoginRecord()
{
$url = 's=Admin.User.GetLastestLoginRecord';
$rs = TestRunner::go($url);
$this->assertArrayHasKey('records', $rs);
}
}