znt/module/zanode/test/model/gethostbyid.php

34 lines
1 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
declare(strict_types=1);
/**
title=测试 zanodeModel->getHostByID().
timeout=0
cid=19830
- 获取ID为1的主机的id,type,extranet
- 属性id @1
- 属性type @node
- 属性extranet @10.0.0.1
- 获取ID为10的主机的id,type,extranet
- 属性id @10
- 属性type @physics
- 属性extranet @10.0.0.10
- 获取ID为0的主机ID为0的主机不存在,返回false @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
zenData('host')->loadYaml('host')->gen(10);
$ipList = array(1, 10, 0);
$zanode = new zanodeModelTest();
r($zanode->getHostByID($ipList[0])) && p('id,type,extranet') && e('1,node,10.0.0.1'); //获取ID为1的主机的id,type,extranet
r($zanode->getHostByID($ipList[1])) && p('id,type,extranet') && e('10,physics,10.0.0.10'); //获取ID为10的主机的id,type,extranet
r($zanode->getHostByID($ipList[2])) && p('') && e('0'); //获取ID为0的主机ID为0的主机不存在,返回false