context->setUid(888); $this->adminApiApps = new \Platform\Api\Apps(); } 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->adminApiApps->getRules(); $this->assertTrue(is_array($rs)); } /** * @group testGetAppList */ public function testGetAppList() { $domain = new AppsDomain(); $domain->addApp('appName_testGetAppList', 'appKey_testGetAppListplatform', 'appSecret_123_platform', 0, 888); $domain->addApp('appName_testGetAppList', 'appKey_testGetAppListplatform22', 'appSecret_123_platform', 0, 888); $url = 's=Platform.Apps.GetAppList'; $rs = TestRunner::go($url); $this->assertNotEmpty($rs['list']); } /** * @group testAddApp */ public function testAddApp() { $url = 's=Platform.Apps.AddApp&app_key=testAddApp&app_secret=xxx&appName=testAddApp&app_owner=hhhhhhhh&apply_reason=test'; $rs = TestRunner::go($url); $this->assertTrue($rs['is_add']); return $rs['app_key']; } /** * @group testAddApp * @depends testAddApp */ public function testGetMyApp($appkey) { $url = 's=Platform.Apps.GetMyAppInfo&app_key='.$appkey.'&app_secret=xxx&appName=testAddApp&app_owner=hhhhhhhh'; $rs = TestRunner::go($url); $this->assertNotEmpty($rs['info']); $this->assertEquals('testAddApp', $rs['info']['app_name']); } /** */ public function testEditApp() { $url = 's=Platform.Apps.AddApp&app_key=testAddApp&app_secret=xxx&appName=testAddApp&app_owner=hhhhhhhh&apply_reason=test'; $rs = TestRunner::go($url); $this->assertTrue($rs['is_add']); $url = 's=Platform.Apps.EditMyApp&&app_secret=xxx&appName=testAddApp&app_owner=hhhhhhhh22&app_icon=1234567&apply_reason=99999&app_key='.$rs['app_key']; $rs = TestRunner::go($url); $this->assertTrue($rs['is_updated']); } }