+ Add unit test case for cne->getSettingsMapping.
This commit is contained in:
@@ -176,4 +176,22 @@ class cneTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getSettingsMapping method.
|
||||
*
|
||||
* @param array $maps
|
||||
* @access public
|
||||
* @return object|null
|
||||
*/
|
||||
public function getSettingsMappingTest(array $maps = array()): object|null
|
||||
{
|
||||
$this->objectModel->error = new stdclass();
|
||||
$instance = $this->objectModel->loadModel('instance')->getByID(1);
|
||||
|
||||
$result = $this->objectModel->getSettingsMapping($instance, $maps);
|
||||
if(!empty($this->objectModel->error->message)) return $this->objectModel->error;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 cneModel->getSettingsMapping();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 获取管理员账号信息
|
||||
- 属性admin_username @root
|
||||
- 属性z_username @zentao-bot
|
||||
- 获取管理员账号信息
|
||||
- 属性admin_username @~~
|
||||
- 属性z_username @zentao-bot
|
||||
|
||||
*/
|
||||
|
||||
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->getSettingsMappingTest()) && p('admin_username,z_username') && e('root,zentao-bot'); // 获取管理员账号信息
|
||||
|
||||
$maps = array(
|
||||
array(
|
||||
"key" => "z_username",
|
||||
"path" => "z_username",
|
||||
"type" => "secret"
|
||||
),
|
||||
array(
|
||||
"key" => "z_password",
|
||||
"path" => "z_password",
|
||||
"type" => "secret"
|
||||
)
|
||||
);
|
||||
r($cneModel->getSettingsMappingTest($maps)) && p('admin_username,z_username') && e('~~,zentao-bot'); // 获取管理员账号信息
|
||||
Reference in New Issue
Block a user