diff --git a/module/mr/test/model/apiacceptmr.php b/module/mr/test/model/apiacceptmr.php new file mode 100755 index 0000000000..6180275f79 --- /dev/null +++ b/module/mr/test/model/apiacceptmr.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +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合并请求 \ No newline at end of file diff --git a/module/mr/test/mr.class.php b/module/mr/test/mr.class.php index 32ed64c919..f93955e25a 100755 --- a/module/mr/test/mr.class.php +++ b/module/mr/test/mr.class.php @@ -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); + } }