* [misc] Enhance unit tests for repoZen::checkConnection() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-25 09:16:55 +08:00
co-authored by Claude
parent ada33b23b0
commit 63f4ece3cd
+42 -2
View File
@@ -21,7 +21,7 @@ su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$repoTest = new repoZenTest();
// 4. 强制要求:必须包含至少8个测试步骤
// 4. 强制要求:必须包含至少5个测试步骤,这里扩展为13个测试步骤提升覆盖率
r($repoTest->checkConnectionTest()) && p() && e('0'); // 步骤1:空POST数据边界验证,测试方法对无参数调用的处理
r($repoTest->checkConnectionTest(array(
@@ -76,4 +76,44 @@ r($repoTest->checkConnectionTest(array(
'name' => 'test-repo',
'serviceProject' => '',
'serviceHost' => '2'
))) && p() && e('0'); // 步骤8:Gogs缺少serviceProject参数验证,检查serviceProject必要参数
))) && p() && e('0'); // 步骤8:Gogs缺少serviceProject参数验证,检查serviceProject必要参数
r($repoTest->checkConnectionTest(array(
'SCM' => 'Subversion',
'client' => 'git',
'account' => 'testuser',
'password' => 'testpass',
'path' => 'https://svn.example.com/repo'
))) && p() && e('0'); // 步骤9:Subversion无效客户端验证,测试非SVN客户端的拒绝处理
r($repoTest->checkConnectionTest(array(
'SCM' => 'Git',
'client' => 'git',
'account' => '',
'password' => '',
'encoding' => 'UTF-8',
'path' => '/root'
))) && p() && e('0'); // 步骤10:Git权限受限目录验证,测试访问权限受限目录的处理
r($repoTest->checkConnectionTest(array(
'SCM' => 'Subversion',
'client' => 'svn',
'account' => 'testuser',
'password' => 'testpass',
'encoding' => 'GBK',
'path' => 'https://svn.example.com/repo'
))) && p() && e('0'); // 步骤11:编码转换测试,验证非UTF-8编码的路径处理
r($repoTest->checkConnectionTest(array(
'SCM' => 'Gitea',
'name' => 'test-repo',
'serviceProject' => '123',
'serviceHost' => '1'
))) && p() && e('0'); // 步骤12:Gitea完整参数但API失败验证,检查API连接失败处理
r($repoTest->checkConnectionTest(array(
'SCM' => 'Gogs',
'name' => 'test-repo',
'serviceProject' => '456',
'serviceHost' => '2'
))) && p() && e('0'); // 步骤13:Gogs完整参数但API失败验证,检查API连接失败处理