znt/module/repo/test/model/getrepolistbyurl.php

45 lines
1.8 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=测试 repoModel::getRepoListByUrl();
timeout=0
cid=18077
- 执行repoTest模块的getRepoListByUrlTest方法参数是'' 属性message @Url is empty.
- 执行repoTest模块的getRepoListByUrlTest方法参数是'http://invalid-server.example.com/repo.git' 属性message @No matched gitlab.
- 执行repoTest模块的getRepoListByUrlTest方法参数是'http://unknown-server.com/project/repo.git' 属性message @No matched gitlab.
- 执行repoTest模块的getRepoListByUrlTest方法参数是$nullUrl 属性message @Url is empty.
- 执行repoTest模块的getRepoListByUrlTest方法参数是'http://test.com/项目/仓库.git' 属性message @No matched gitlab.
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
// 准备测试数据
zenData('pipeline')->loadYaml('pipeline_getrepolistbyurl')->gen(3);
zenData('repo')->loadYaml('repo_getrepolistbyurl')->gen(8);
// 登录管理员用户
su('admin');
// 创建测试实例
$repoTest = new repoModelTest();
// 测试步骤1空URL输入测试
r($repoTest->getRepoListByUrlTest('')) && p('message') && e('Url is empty.');
// 测试步骤2格式正确但不匹配的URL测试
r($repoTest->getRepoListByUrlTest('http://invalid-server.example.com/repo.git')) && p('message') && e('No matched gitlab.');
// 测试步骤3有效URL但无匹配gitlab服务器测试
r($repoTest->getRepoListByUrlTest('http://unknown-server.com/project/repo.git')) && p('message') && e('No matched gitlab.');
// 测试步骤4NULL类型URL处理转换为空字符串
$nullUrl = null;
r($repoTest->getRepoListByUrlTest($nullUrl)) && p('message') && e('Url is empty.');
// 测试步骤5特殊字符URL处理测试
r($repoTest->getRepoListByUrlTest('http://test.com/项目/仓库.git')) && p('message') && e('No matched gitlab.');