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

58 lines
1.9 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::url();
timeout=0
cid=16827
- 步骤1正常情况 @//example.com
- 步骤2端口443不添加 @//test.example.com
- 步骤3自定义端口 @//dev.example.com:8443/
- 步骤4空域名 @//
- 步骤5端口8080 @//staging.example.com:8080/
*/
// 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. 测试步骤必须包含至少5个测试步骤
// 步骤1测试正常域名情况无端口环境变量
$instance1 = new stdClass();
$instance1->domain = 'example.com';
putenv('APP_HTTPS_PORT=');
r($instanceTest->urlTest($instance1)) && p() && e('//example.com'); // 步骤1正常情况
// 步骤2测试正常域名情况端口为443
$instance2 = new stdClass();
$instance2->domain = 'test.example.com';
putenv('APP_HTTPS_PORT=443');
r($instanceTest->urlTest($instance2)) && p() && e('//test.example.com'); // 步骤2端口443不添加
// 步骤3测试正常域名情况自定义端口8443
$instance3 = new stdClass();
$instance3->domain = 'dev.example.com';
putenv('APP_HTTPS_PORT=8443');
r($instanceTest->urlTest($instance3)) && p() && e('//dev.example.com:8443/'); // 步骤3自定义端口
// 步骤4测试空域名情况
$instance4 = new stdClass();
$instance4->domain = '';
putenv('APP_HTTPS_PORT=');
r($instanceTest->urlTest($instance4)) && p() && e('//'); // 步骤4空域名
// 步骤5测试域名包含端口情况环境变量端口为8080
$instance5 = new stdClass();
$instance5->domain = 'staging.example.com';
putenv('APP_HTTPS_PORT=8080');
r($instanceTest->urlTest($instance5)) && p() && e('//staging.example.com:8080/'); // 步骤5端口8080