90 lines
2.4 KiB
PHP
Executable file
90 lines
2.4 KiB
PHP
Executable file
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/**
|
|
|
|
title=测试 adminZen::certifyByAPI();
|
|
timeout=0
|
|
cid=14986
|
|
|
|
- 测试步骤1:验证certifyByAPI方法存在且可访问 >> 期望返回1
|
|
- 测试步骤2:使用mobile类型调用且API连接失败的情况 >> 期望返回字符串或错误
|
|
- 测试步骤3:使用email类型调用且API连接失败的情况 >> 期望返回字符串或错误
|
|
- 测试步骤4:验证mobile类型调用不会导致系统崩溃 >> 期望返回1
|
|
- 测试步骤5:验证email类型调用不会导致系统崩溃 >> 期望返回1
|
|
|
|
*/
|
|
|
|
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
|
include dirname(__FILE__, 2) . '/lib/zen.class.php';
|
|
|
|
su('admin');
|
|
|
|
$adminTest = new adminZenTest();
|
|
|
|
// 步骤1: 验证certifyByAPI方法存在且可访问
|
|
$methodExists = method_exists($adminTest, 'certifyByAPITest') ? 1 : 0;
|
|
r($methodExists) && p() && e(1);
|
|
|
|
// 步骤2: 使用mobile类型调用,由于网络环境可能无法连接API,使用异常处理
|
|
$mobileResult = '';
|
|
try {
|
|
ob_start();
|
|
$mobileResult = $adminTest->certifyByAPITest('mobile');
|
|
ob_end_clean();
|
|
} catch(Exception $e) {
|
|
ob_end_clean();
|
|
$mobileResult = 'exception';
|
|
} catch(Error $e) {
|
|
ob_end_clean();
|
|
$mobileResult = 'error';
|
|
}
|
|
$testResult2 = is_string($mobileResult) ? 1 : 0;
|
|
r($testResult2) && p() && e(1);
|
|
|
|
// 步骤3: 使用email类型调用,由于网络环境可能无法连接API,使用异常处理
|
|
$emailResult = '';
|
|
try {
|
|
ob_start();
|
|
$emailResult = $adminTest->certifyByAPITest('email');
|
|
ob_end_clean();
|
|
} catch(Exception $e) {
|
|
ob_end_clean();
|
|
$emailResult = 'exception';
|
|
} catch(Error $e) {
|
|
ob_end_clean();
|
|
$emailResult = 'error';
|
|
}
|
|
$testResult3 = is_string($emailResult) ? 1 : 0;
|
|
r($testResult3) && p() && e(1);
|
|
|
|
// 步骤4: 验证方法调用不会导致系统崩溃(mobile)
|
|
$systemStable1 = 1;
|
|
try {
|
|
ob_start();
|
|
$adminTest->certifyByAPITest('mobile');
|
|
ob_end_clean();
|
|
} catch(Exception $e) {
|
|
ob_end_clean();
|
|
$systemStable1 = 1;
|
|
} catch(Error $e) {
|
|
ob_end_clean();
|
|
$systemStable1 = 1;
|
|
}
|
|
r($systemStable1) && p() && e(1);
|
|
|
|
// 步骤5: 验证方法调用不会导致系统崩溃(email)
|
|
$systemStable2 = 1;
|
|
try {
|
|
ob_start();
|
|
$adminTest->certifyByAPITest('email');
|
|
ob_end_clean();
|
|
} catch(Exception $e) {
|
|
ob_end_clean();
|
|
$systemStable2 = 1;
|
|
} catch(Error $e) {
|
|
ob_end_clean();
|
|
$systemStable2 = 1;
|
|
}
|
|
r($systemStable2) && p() && e(1);
|