* adjust for unit test.
This commit is contained in:
123
test/model/mr/apigetsameopened.php
Normal file
123
test/model/mr/apigetsameopened.php
Normal file
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 mrModel::apiGetSameOpened();
|
||||
cid=0
|
||||
pid=0
|
||||
|
||||
使用正确的gitlabID,sourceProject,sourceBranch,targetProject,targetBranch >> success
|
||||
使用空的gitlabID >> null
|
||||
使用空的sourceProject >> null
|
||||
使用空的sourceBranch >> null
|
||||
使用空的targetProject >> null
|
||||
使用空的targetBranch >> null
|
||||
使用错误的gitlabID >> null
|
||||
使用错误的sourceProject >> null
|
||||
使用错误的sourceBranch >> null
|
||||
使用错误的targetProject >> null
|
||||
使用错误的targetBranch >> null
|
||||
|
||||
*/
|
||||
$mrModel = $tester->loadModel('mr');
|
||||
|
||||
$gitlabID = '2';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if(isset($result->iid)) $result = 'success';
|
||||
r($result) && p() && e('success'); //使用正确的gitlabID, sourceProject,sourceBranch,targetProject,targetBranch
|
||||
|
||||
$gitlabID = '';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用空的gitlabID
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用空的sourceProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = '';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用空的sourceBranch
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用空的targetProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = '';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用空的targetBranch
|
||||
|
||||
$gitlabID = 'test';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用错误的gitlabID
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = 'test';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用错误的sourceProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用错误的sourceBranch
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = 'test';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用错误的targetProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'main';
|
||||
$result = $mrModel->apiGetSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
if($result === null) $result = 'null';
|
||||
r($result) && p() && e('null'); //使用错误的targetBranch
|
||||
112
test/model/mr/checksameopened.php
Normal file
112
test/model/mr/checksameopened.php
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 mrModel::checkSameOpened();
|
||||
cid=0
|
||||
pid=0
|
||||
|
||||
使用正确的gitlabID,sourceProject,sourceBranch,targetProject,targetBranch >> fail
|
||||
使用空的gitlabID >> success
|
||||
使用空的sourceProject >> success
|
||||
使用空的sourceBranch >> success
|
||||
使用空的targetProject >> success
|
||||
使用空的targetBranch >> success
|
||||
使用错误的gitlabID >> success
|
||||
使用错误的sourceProject >> success
|
||||
使用错误的sourceBranch >> success
|
||||
使用错误的targetProject >> success
|
||||
使用错误的targetBranch >> success
|
||||
|
||||
*/
|
||||
$mrModel = $tester->loadModel('mr');
|
||||
|
||||
$gitlabID = '2';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('fail'); //使用正确的gitlabID, sourceProject,sourceBranch,targetProject,targetBranch
|
||||
|
||||
$gitlabID = '';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用空的gitlabID
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用空的sourceProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = '';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用空的sourceBranch
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用空的targetProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = '';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用空的targetBranch
|
||||
|
||||
$gitlabID = 'test';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用错误的gitlabID
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = 'test';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用错误的sourceProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用错误的sourceBranch
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = 'test';
|
||||
$targetBranch = 'master';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用错误的targetProject
|
||||
|
||||
$gitlabID = '1';
|
||||
$sourceProject = '42';
|
||||
$sourceBranch = 'branch-08';
|
||||
$targetProject = '42';
|
||||
$targetBranch = 'main';
|
||||
$result = $mrModel->checkSameOpened($gitlabID, $sourceProject, $sourceBranch, $targetProject, $targetBranch);
|
||||
r($result) && p('result') && e('success'); //使用错误的targetBranch
|
||||
26
test/model/mr/convertapierror.php
Normal file
26
test/model/mr/convertapierror.php
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 mrModel::convertApiError();
|
||||
cid=0
|
||||
pid=0
|
||||
|
||||
使用正确的message >> success
|
||||
使用空的message >> success
|
||||
|
||||
*/
|
||||
$mrModel = $tester->loadModel('mr');
|
||||
|
||||
$message = array();
|
||||
$message[0] = 'Another open merge request already exists for this source branch: !11';
|
||||
$result = $mrModel->convertApiError($message);
|
||||
if($result != $message[0]) $result = 'success';
|
||||
r($result) && p('') && e('success'); //使用正确的message
|
||||
|
||||
$message = '';
|
||||
$result = $mrModel->convertApiError($message);
|
||||
if(empty($result)) $result = 'success';
|
||||
r($result) && p('') && e('success'); //使用空的message
|
||||
Reference in New Issue
Block a user