appCommonApiInfoUtil = new \Base\Common\ApiInfoUtil(); } protected function tearDown() { // 输出本次单元测试所执行的SQL语句 // var_dump(\PhalApi\DI()->tracer->getSqls()); // 输出本次单元测试所涉及的追踪埋点 // var_dump(\PhalApi\DI()->tracer->getStack()); } /** * @ runInSeparateProcess * @group testGetApiNum */ public function testGetApiNum() { $rs = @$this->appCommonApiInfoUtil::getApiNum(); $this->assertTrue(is_int($rs)); $this->assertGreaterThan(1, $rs); return $rs; } /** * @depends testGetApiNum * @ runInSeparateProcess * @group testGetApiInfo */ public function testGetApiInfo($total) { $namespace1 = 'Admin'; $namespace2 = 'App'; $rs1 = $this->appCommonApiInfoUtil::getApiInfo($namespace1); $rs2 = $this->appCommonApiInfoUtil::getApiInfo($namespace2); $this->assertTrue(is_array($rs1)); $this->assertNotEmpty($rs1); $this->assertTrue(is_array($rs2)); $this->assertNotEmpty($rs2); $this->assertGreaterThan(1, $rs1['total']); $this->assertGreaterThan(1, $rs2['total']); } public function testCheckApiIsExist() { $this->assertTrue(\Base\Common\ApiInfoUtil::checkApiIsExist('App.Auth.ApplyToken')); $this->assertFalse(\Base\Common\ApiInfoUtil::checkApiIsExist('App.Auth')); $this->assertFalse(\Base\Common\ApiInfoUtil::checkApiIsExist('App.Auth.ApplyTokenXXXXX')); } }