znt/module/zanode/test/tao/gethostsbyidlist.php

42 lines
1.5 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 zanodeTao::getHostsByIDList();
timeout=0
cid=19848
- 步骤1正常多个主机ID查询属性count @3
- 步骤2单个存在主机ID查询
- 属性count @1
- 属性firstId @1
- 属性firstStatus @online
- 步骤3不存在主机ID查询属性count @0
- 步骤4空数组参数查询属性count @0
- 步骤5混合存在与不存在ID查询属性count @2
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/tao.class.php';
// 2. zendata数据准备根据需要配置
$table = zenData('host');
$table->id->range('1-10');
$table->status->range('online{7},offline{3}');
$table->gen(10);
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$zanodeTest = new zanodeTaoTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r($zanodeTest->getHostsByIDListTest(array(1, 2, 3))) && p('count') && e('3'); // 步骤1正常多个主机ID查询
r($zanodeTest->getHostsByIDListTest(array(1))) && p('count,firstId,firstStatus') && e('1,1,online'); // 步骤2单个存在主机ID查询
r($zanodeTest->getHostsByIDListTest(array(999))) && p('count') && e('0'); // 步骤3不存在主机ID查询
r($zanodeTest->getHostsByIDListTest(array())) && p('count') && e('0'); // 步骤4空数组参数查询
r($zanodeTest->getHostsByIDListTest(array(1, 999, 2))) && p('count') && e('2'); // 步骤5混合存在与不存在ID查询