znt/module/admin/test/zen/sendcodebyapi.php

89 lines
2.1 KiB
PHP
Raw Permalink Normal View History

#!/usr/bin/env php
<?php
/**
title=测试 adminZen::sendCodeByAPI();
timeout=0
cid=14989
- 执行$methodExists @1
- 执行$testResult2 @1
- 执行$testResult3 @1
- 执行$systemStable1 @1
- 执行$systemStable2 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
su('admin');
$adminTest = new adminZenTest();
// 步骤1: 验证sendCodeByAPI方法存在且可访问
$methodExists = method_exists($adminTest, 'sendCodeByAPITest') ? 1 : 0;
r($methodExists) && p() && e(1);
// 步骤2: 使用mobile类型调用,由于网络环境可能无法连接API,使用异常处理
$mobileResult = '';
try {
ob_start();
$mobileResult = $adminTest->sendCodeByAPITest('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->sendCodeByAPITest('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->sendCodeByAPITest('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->sendCodeByAPITest('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);