* Add unit test for insstance.

This commit is contained in:
sunguangming
2023-12-27 18:43:21 +08:00
parent 71b975b22c
commit df29039cb6
2 changed files with 59 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
/**
title=instanceModel->dbListToOptions();
timeout=0
cid=1
- 查看转换后的options数量 @2
- 查看转换后的options属性mysql @mysql-server
- 查看转换后的options属性sqllite @sqllite-server
*/
global $tester;
$tester->loadModel('instance');
$dbList = array();
$dbList[1] = new stdClass();
$dbList[1]->name = 'mysql';
$dbList[1]->alias = 'mysql-server';
$dbList[2] = new stdClass();
$dbList[2]->name = 'sqllite';
$dbList[2]->alias = 'sqllite-server';
$options = $tester->instance->dbListToOptions($dbList);
r(count($options)) && p() && e('2'); // 查看转换后的options数量
r($options) && p('mysql') && e('mysql-server'); // 查看转换后的options
r($options) && p('sqllite') && e('sqllite-server'); // 查看转换后的options
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
/**
title=instanceModel->domainExists();
timeout=0
cid=1
- 查看过滤后的内存选项是否正确 @6
- 查看过滤后的内存选项是否正确 @2
*/
global $tester;
$tester->loadModel('instance');
$resources = new stdclass();
$resources->min = new stdclass();
$resources->min->memory = 1048576 * 1024;
r(count($tester->instance->filterMemOptions($resources))) && p('') && e('6'); // 查看过滤后的内存选项是否正确
$resources->min->memory = 16777216 * 1024;
r(count($tester->instance->filterMemOptions($resources))) && p('') && e('2'); // 查看过滤后的内存选项是否正确