Files
phalapi-pro/tests/platform/Api/Rigths_Test.php
2022-03-21 11:16:38 +08:00

70 lines
1.7 KiB
PHP

<?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);
}
}
}