znt/module/metric/test/zen/endtime.php

38 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=测试 metricZen::endTime();
timeout=0
cid=17186
- 步骤1正常计算时间差验证返回值格式 @string
- 步骤2测试时间差为非负值 @1
- 步骤3测试较小时间差的计算 @string
- 步骤4测试返回值数字格式化精度 @1
- 步骤5测试无效时间输入的处理 @string
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/metriczen.unittest.class.php';
// 2. 用户登录(选择合适角色)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$metricZenTest = new metricZenTest();
// 4. 强制要求必须包含至少5个测试步骤
$currentTime = microtime(true);
r(gettype($metricZenTest->endTimeZenTest($currentTime))) && p() && e('string'); // 步骤1正常计算时间差验证返回值格式
$timeStart = microtime(true);
$result = $metricZenTest->endTimeZenTest($timeStart);
r(floatval($result) >= 0 ? '1' : '0') && p() && e('1'); // 步骤2测试时间差为非负值
$beginTime = microtime(true) - 0.001;
r(gettype($metricZenTest->endTimeZenTest($beginTime))) && p() && e('string'); // 步骤3测试较小时间差的计算
$timeResult = $metricZenTest->endTimeZenTest($currentTime - 1.23456);
r(strlen($timeResult) == 7 && strpos($timeResult, '.') == 1 ? '1' : '0') && p() && e('1'); // 步骤4测试返回值数字格式化精度
r(gettype($metricZenTest->endTimeZenTest(0))) && p() && e('string'); // 步骤5测试无效时间输入的处理