+ Add unit test case for mr->apiAcceptMR.

This commit is contained in:
caoyanyi
2023-12-22 13:12:22 +08:00
parent 93311eed6f
commit 760f9c3ca8
2 changed files with 51 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env php
<?php
/**
title=测试 mrModel::apiAcceptMR();
timeout=0
cid=0
- 不存在的主机 @0
- 已关闭的gitlab合并请求属性message @404 Not found
- 已关闭的gitea合并请求 @0
- 已关闭的gogs合并请求 @0
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/mr.class.php';
zdTable('pipeline')->gen(5);
$mr = zdTable('mr')->config('mr');
$mr->mriid->range(45);
$mr->gen(10);
$mrModel = new mrTest();
$noHost = 6;
r($mrModel->apiAcceptMRTester($noHost)) && p() && e('0'); // 不存在的主机
$gitlab = 1;
r($mrModel->apiAcceptMRTester($gitlab)) && p('message') && e('404 Not found'); // 已关闭的gitlab合并请求
$gitea = 4;
r($mrModel->apiAcceptMRTester($gitea)) && p() && e('0'); // 已关闭的gitea合并请求
$gogs = 5;
r($mrModel->apiAcceptMRTester($gogs)) && p() && e('0'); // 已关闭的gogs合并请求
+13
View File
@@ -424,4 +424,17 @@ class mrTest
return $this->objectModel->dao->select('*')->from(TABLE_ACTION)->orderBy('id_desc')->fetchAll('id');
}
/**
* Test apiAcceptMR method.
*
* @param int $MRID
* @access public
* @return object|null
*/
public function apiAcceptMrTester(int $MRID): object|null
{
$MR = $this->objectModel->fetchByID($MRID);
return $this->objectModel->apiAcceptMR($MR);
}
}