+ Add unit test case for svn methods.

This commit is contained in:
caoyanyi
2023-12-12 14:07:21 +08:00
parent 8c36712db0
commit 24fa9e95ba
5 changed files with 23 additions and 12 deletions
+4 -8
View File
@@ -241,8 +241,6 @@ class svnModel extends model
public function setRepo(object $repo): bool
{
$this->setClient($repo);
if(empty($this->client)) return false;
$this->setRepoRoot($repo);
return true;
}
@@ -313,13 +311,13 @@ class svnModel extends model
* @access public
* @return array
*/
public function getRepoLogs(object $repo, int $fromRevision): array|false
public function getRepoLogs(object $repo, int $fromRevision): array
{
/* The svn log command. */
$scm = $this->app->loadClass('scm');
$scm->setEngine($repo);
$logs = $scm->log('', $fromRevision);
if(empty($logs)) return false;
if(empty($logs)) return array();
/* Process logs. */
foreach($logs as $log)
@@ -350,7 +348,6 @@ class svnModel extends model
if(!$repo) return false;
$this->setClient($repo);
if(empty($this->client)) return false;
putenv('LC_CTYPE=en_US.UTF-8');
$oldRevision = $revision - 1;
@@ -382,7 +379,6 @@ class svnModel extends model
if(!$repo) return false;
$this->setClient($repo);
if(empty($this->client)) return false;
putenv('LC_CTYPE=en_US.UTF-8');
@@ -403,10 +399,10 @@ class svnModel extends model
* Get repo by url.
*
* @param string $url
* @access public
* @access private
* @return object|false
*/
public function getRepoByURL(string $url): object|false
private function getRepoByURL(string $url): object|false
{
if(empty($this->repos)) $this->setRepos();
foreach($this->repos as $repo)
+2 -2
View File
@@ -8,7 +8,7 @@ timeout=0
cid=1
- 获取不到数据时,提示错误信息 @5
- 获取第一条svn记录的name和SCM属性属性1 @http://10.0.7.237/svn/repo/unit_test1
- 获取第一条svn记录的path属性属性1 @http://10.0.7.237/svn/repo/unit_test1
- 获取不到数据时,提示错误信息 @You must set one svn repo.
*/
@@ -31,4 +31,4 @@ dao::$cache = array();
ob_start();
$svn->getRepos();
$result = ob_get_clean();
r($result) && p() && e('You must set one svn repo.'); // 获取不到数据时,提示错误信息
r($result) && p() && e('You must set one svn repo.'); // 获取不到数据时,提示错误信息
+3 -1
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env php
<?php
/**
title=svnModel->run();
timeout=0
cid=1
@@ -23,4 +25,4 @@ su('admin');
$svn = new svnTest();
r($svn->runTest()) && p('commit,comment,committer') && e('2,+ Add secondary file.,user'); // 更新svn提交信息到禅道,检查第二条记录是否正确
r($svn->runTest()) && p('commit,comment,committer') && e('2,+ Add secondary file.,user'); // 更新svn提交信息到禅道,检查第二条记录是否正确
+13
View File
@@ -22,4 +22,17 @@ class svnTest
return $this->objectModel->dao->select('*')->from(TABLE_REPOHISTORY)->where('id')->eq(2)->fetch();
}
public function getRepoLogsTest(int $version): object|bool
{
$this->objectModel->setRepos();
ob_start();
$repo = $this->objectModel->repos[1];
$logs = $this->objectModel->getRepoLogs($repo, $version);
$error = ob_get_clean();
if($error) return $error;
return $logs[count($logs) - 1];
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ fields:
- field: encoding
range: "`utf-8`"
- field: SCM
range: Subversion{3},Gitlba,Gitea,Gogs
range: Subversion{3},Gitlab,Gitea,Gogs
- field: client
range: /usr/bin/svn
- field: commits