znt/module/instance/test/model/enoughmemory.php

49 lines
1.6 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=测试 instanceModel::enoughMemory();
timeout=0
cid=16792
- 步骤1正常情况-低内存需求测试环境集群资源为0 @0
- 步骤2高内存需求 @0
- 步骤3边界值测试 @0
- 步骤4零内存需求 @1
- 步骤5负数内存需求 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$instanceTest = new instanceModelTest();
// 4. 准备测试数据 - 创建不同内存需求的应用对象
$lowMemoryApp = new stdclass;
$lowMemoryApp->memory = 512; // 512MB
$highMemoryApp = new stdclass;
$highMemoryApp->memory = 16384; // 16GB
$boundaryApp = new stdclass;
$boundaryApp->memory = 1000; // 假设为边界值
$zeroMemoryApp = new stdclass;
$zeroMemoryApp->memory = 0;
$negativeMemoryApp = new stdclass;
$negativeMemoryApp->memory = -100;
// 5. 强制要求必须包含至少5个测试步骤
r($instanceTest->enoughMemoryTest($lowMemoryApp)) && p() && e('0'); // 步骤1正常情况-低内存需求测试环境集群资源为0
r($instanceTest->enoughMemoryTest($highMemoryApp)) && p() && e('0'); // 步骤2高内存需求
r($instanceTest->enoughMemoryTest($boundaryApp)) && p() && e('0'); // 步骤3边界值测试
r($instanceTest->enoughMemoryTest($zeroMemoryApp)) && p() && e('1'); // 步骤4零内存需求
r($instanceTest->enoughMemoryTest($negativeMemoryApp)) && p() && e('1'); // 步骤5负数内存需求