3.8.1
This commit is contained in:
69
tests/platform/Api/Rigths_Test.php
Normal file
69
tests/platform/Api/Rigths_Test.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* PhalApi_Platform\Api\Rights_Test
|
||||
*
|
||||
* 针对 ../src/platform/Api/Rights.php Platform\Api\Rights 类的PHPUnit单元测试
|
||||
*
|
||||
* @author: dogstar 20200408
|
||||
*/
|
||||
|
||||
namespace tests\Platform\Api;
|
||||
use Platform\Api\Rights;
|
||||
use PhalApi\Helper\TestRunner;
|
||||
use Base\Domain\Apps as AppsDomain;
|
||||
|
||||
class PhpUnderControl_PlatformApiRights_Test extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public $platformApiRights;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
\PhalApi\DI()->context->setUid(8889);
|
||||
|
||||
$this->platformApiRights = new \Platform\Api\Rights();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
// 输出本次单元测试所执行的SQL语句
|
||||
// var_dump(\PhalApi\DI()->tracer->getSqls());
|
||||
|
||||
// 输出本次单元测试所涉及的追踪埋点
|
||||
// var_dump(\PhalApi\DI()->tracer->getStack());
|
||||
|
||||
\PhalApi\DI()->context->setUid(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group testGetRules
|
||||
*/
|
||||
public function testGetRules()
|
||||
{
|
||||
$rs = $this->platformApiRights->getRules();
|
||||
$this->assertTrue(is_array($rs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group testGetAllAppApis
|
||||
*/
|
||||
public function testGetAllAppApis()
|
||||
{
|
||||
$domain = new AppsDomain();
|
||||
$domain->addApp('appName_testGetAppList', 'appKey_testGetAppListplatform8889', 'appSecret_123_platform', 0, 8889);
|
||||
|
||||
$url = 's=Platform.Rights.GetAllAppApis&app_key=appKey_testGetAppListplatform8889';
|
||||
$rs = TestRunner::go($url);
|
||||
// var_dump($rs);
|
||||
|
||||
$this->assertNotEmpty($rs['apis']);
|
||||
foreach ($rs['apis'] as $it) {
|
||||
$this->assertArrayHasKey('service', $it);
|
||||
$this->assertArrayHasKey('title', $it);
|
||||
$this->assertArrayHasKey('is_allow', $it);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user