znt/module/dev/test/model/getapidata.php

36 lines
1.4 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=测试 devModel::getAPIData();
timeout=0
cid=16000
- 步骤1默认参数apiID=0测试返回3个元素的数组 @3
- 步骤2指定存在的API ID测试第0条的id属性 @1
- 步骤3不存在的API ID测试返回3个元素的数组 @3
- 步骤4验证typeList数组长度 @12
- 步骤5验证treeMenu数组长度 @16
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. zendata数据准备根据需要配置
// 不需要准备数据因为getAPIData方法使用固定的demo数据文件
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$devTest = new devModelTest();
// 5. 🔴 强制要求必须包含至少5个测试步骤
r(count($devTest->getAPIDataTest(0, '16.0'))) && p() && e(3); // 步骤1默认参数apiID=0测试返回3个元素的数组
r($devTest->getAPIDataTest(1, '16.0')) && p('0:id') && e(1); // 步骤2指定存在的API ID测试
r(count($devTest->getAPIDataTest(999999, '16.0'))) && p() && e(3); // 步骤3不存在的API ID测试返回3个元素的数组
r(count($devTest->getAPIDataTest(0, '16.0')[1])) && p() && e(12); // 步骤4验证typeList数组长度
r(count($devTest->getAPIDataTest(0, '16.0')[2])) && p() && e(16); // 步骤5验证treeMenu数组长度