* Add saveimportedissue unit test
This commit is contained in:
@@ -1665,6 +1665,7 @@ class gitlabModel extends model
|
||||
$label = $this->createZentaoObjectLabel($gitlabID, $projectID, $objectType, (string)$objectID);
|
||||
$data = new stdclass;
|
||||
if(isset($label->name)) $data->labels = $label->name;
|
||||
if(isset($label->message) && $label->message == 'Label already exists') $data->labels = sprintf($this->config->gitlab->zentaoObjectLabel->name, $objectType, $objectID);
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/issues/{$issue->iid}");
|
||||
|
||||
@@ -314,6 +314,27 @@ class gitlabTest
|
||||
return $result ? $this->gitlab->getRelationByObject($objectType, $object->id) : $result;
|
||||
}
|
||||
|
||||
public function saveImportedIssueTest(int $gitlabID, int $projectID, string $objectType, int $objectID, int $issueID)
|
||||
{
|
||||
$issue = $this->gitlab->apiGetSingleIssue($gitlabID, $projectID, $issueID);
|
||||
|
||||
/* Init issue labels. */
|
||||
$data = new stdclass;
|
||||
$data->labels = '';
|
||||
$apiRoot = $this->gitlab->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}/issues/{$issue->iid}");
|
||||
commonModel::http($url, $data, array(CURLOPT_CUSTOMREQUEST => 'PUT'));
|
||||
|
||||
$object = new stdclass();
|
||||
$object->id = $objectID;
|
||||
$object->product = 1;
|
||||
$object->execution = 1;
|
||||
|
||||
$this->gitlab->saveImportedIssue($gitlabID, $projectID, $objectType, $objectID, $issue, $object);
|
||||
$result = $this->gitlab->apiGetSingleIssue($gitlabID, $projectID, $issueID);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function createUserTest(int $gitlabID, object $gitlabUser)
|
||||
{
|
||||
$result = $this->gitlab->createUser($gitlabID, $gitlabUser);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/gitlab.class.php';
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试gitlabModel->saveImportedIssue();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 保存导入任务issue。第labels条的0属性 @zentao_task/18
|
||||
- 保存导入bug issue。第labels条的0属性 @zentao_bug/9
|
||||
|
||||
*/
|
||||
|
||||
zdTable('task')->gen(20);
|
||||
zdTable('bug')->gen(10);
|
||||
zdTable('pipeline')->gen(5);
|
||||
zdTable('relation')->config('relation')->gen(4);
|
||||
|
||||
$gitlab = new gitlabTest();
|
||||
|
||||
$gitlabID = 1;
|
||||
$projectID = 2;
|
||||
$issueID = 4;
|
||||
$objectType = 'task';
|
||||
$objectID = 18;
|
||||
r($gitlab->saveImportedIssueTest($gitlabID, $projectID, $objectType, $objectID, $issueID)) && p('labels:0') && e('zentao_task/18'); // 保存导入任务issue。
|
||||
|
||||
$issueID = 3;
|
||||
$objectType = 'bug';
|
||||
$objectID = 9;
|
||||
r($gitlab->saveImportedIssueTest($gitlabID, $projectID, $objectType, $objectID, $issueID)) && p('labels:0') && e('zentao_bug/9'); // 保存导入bug issue。
|
||||
Reference in New Issue
Block a user