+ Add unit test case for cne->appDBList.

This commit is contained in:
caoyanyi
2024-01-02 17:10:39 +08:00
parent 7514a52b67
commit b6cd581c77
2 changed files with 40 additions and 0 deletions
+14
View File
@@ -235,4 +235,18 @@ class cneTest
return $this->objectModel->batchQueryStatus($instances);
}
/**
* Test appDBList method.
*
* @param int $instanceID
* @access public
* @return array
*/
public function appDBListTest(int $instanceID): array
{
$instance = $this->objectModel->loadModel('instance')->getByID($instanceID);
return $this->objectModel->appDBList($instance);
}
}
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
/**
title=测试 cneModel->appDBList();
timeout=0
cid=1
- 获取第一个应用的数据库信息
- 第gitlab-20231226133115-gitlabhq-production条的db_type属性 @postgresql
- 第gitlab-20231226133115-gitlabhq-production条的db_name属性 @gitlabhq_production
- 获取第二个应用的数据库信息 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/cne.class.php';
zdTable('space')->config('space')->gen(2);
zdTable('solution')->config('solution')->gen(1);
zdTable('instance')->config('instance')->gen(2, true, false);
$cneModel = new cneTest();
r($cneModel->appDBListTest(1)) && p('gitlab-20231226133115-gitlabhq-production:db_type,db_name') && e('postgresql,gitlabhq_production'); // 获取第一个应用的数据库信息
r($cneModel->appDBListTest(2)) && p() && e('0'); // 获取第二个应用的数据库信息