1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Integrations\Connectors\SenhorVerdugo; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
class Update extends SenhorVerdugo |
7
|
|
|
{ |
8
|
|
View Code Duplication |
public function issueWorklog() |
|
|
|
|
9
|
|
|
{ |
10
|
|
|
$issueKey = 'TEST-961'; |
11
|
|
|
$workLogid = '12345'; |
12
|
|
|
|
13
|
|
|
try { |
14
|
|
|
$workLog = new Worklog(); |
15
|
|
|
|
16
|
|
|
$workLog->setComment('I did edit previous worklog here.') |
17
|
|
|
->setStarted("2016-05-29 13:15:34") |
18
|
|
|
->setTimeSpent('3d 4h 5m'); |
19
|
|
|
|
20
|
|
|
$issueService = new IssueService(); |
21
|
|
|
|
22
|
|
|
$ret = $issueService->editWorklog($issueKey, $workLog, $workLogid); |
23
|
|
|
|
24
|
|
|
var_dump($ret); |
|
|
|
|
25
|
|
|
} catch (SenhorVerdugoException $e) { |
|
|
|
|
26
|
|
|
$this->assertTrue(false, 'Edit worklog Failed : '.$e->getMessage()); |
27
|
|
|
} |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Perform a transition on an issue |
32
|
|
|
* Note: this library uses goal status names instead of transition names. So, if you want to change issue status to 'Some Status', you should pass that status name to setTransitionName |
33
|
|
|
* i.e. $transition->setTransitionName('Some Status') |
34
|
|
|
* See SenhorVerdugo API reference |
35
|
|
|
*/ |
36
|
|
View Code Duplication |
public function issueStatus() |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$issueKey = "TEST-879"; |
39
|
|
|
|
40
|
|
|
try { |
41
|
|
|
$transition = new Transition(); |
42
|
|
|
$transition->setTransitionName('Resolved'); |
43
|
|
|
$transition->setCommentBody('performing the transition via REST API.'); |
44
|
|
|
|
45
|
|
|
$issueService = new IssueService(); |
46
|
|
|
|
47
|
|
|
$issueService->transition($issueKey, $transition); |
48
|
|
|
} catch (SenhorVerdugoException $e) { |
|
|
|
|
49
|
|
|
$this->assertTrue(false, "add Comment Failed : " . $e->getMessage()); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
View Code Duplication |
public function comment() |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
$issueKey = "TEST-879"; |
56
|
|
|
|
57
|
|
|
try { |
58
|
|
|
$commentId = 12345; |
59
|
|
|
|
60
|
|
|
$issueService = new IssueService(); |
61
|
|
|
|
62
|
|
|
$comment = new Comment(); |
63
|
|
|
$comment->setBody('Updated comments'); |
64
|
|
|
|
65
|
|
|
$issueService->updateComment($issueKey, $commentId, $comment); |
66
|
|
|
|
67
|
|
|
} catch (SenhorVerdugoException $e) { |
|
|
|
|
68
|
|
|
$this->assertTrue(false, 'Delete comment Failed : '.$e->getMessage()); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
View Code Duplication |
public function changeAssignee() |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
|
75
|
|
|
$issueKey = "TEST-879"; |
76
|
|
|
|
77
|
|
|
try { |
78
|
|
|
$issueService = new IssueService(); |
79
|
|
|
|
80
|
|
|
// if assignee is -1, automatic assignee used. |
81
|
|
|
// A null assignee will remove the assignee. |
82
|
|
|
$assignee = 'newAssigneeName'; |
83
|
|
|
|
84
|
|
|
$ret = $issueService->changeAssignee($issueKey, $assignee); |
85
|
|
|
|
86
|
|
|
var_dump($ret); |
|
|
|
|
87
|
|
|
} catch (SenhorVerdugoException $e) { |
|
|
|
|
88
|
|
|
$this->assertTrue(false, "Change Assignee Failed : " . $e->getMessage()); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function issue() |
93
|
|
|
{ |
94
|
|
|
$issueKey = "TEST-879"; |
95
|
|
|
|
96
|
|
|
try { |
97
|
|
|
$issueField = new IssueField(true); |
98
|
|
|
|
99
|
|
|
$issueField->setAssigneeName("admin") |
100
|
|
|
->setPriorityName("Blocker") |
101
|
|
|
->setIssueType("Task") |
102
|
|
|
->addLabel("test-label-first") |
103
|
|
|
->addLabel("test-label-second") |
104
|
|
|
->addVersion("1.0.1") |
105
|
|
|
->addVersion("1.0.2") |
106
|
|
|
->setDescription("This is a shorthand for a set operation on the summary field"); |
107
|
|
|
|
108
|
|
|
// optionally set some query params |
109
|
|
|
$editParams = [ |
110
|
|
|
'notifyUsers' => false, |
111
|
|
|
]; |
112
|
|
|
|
113
|
|
|
$issueService = new IssueService(); |
114
|
|
|
|
115
|
|
|
// You can set the $paramArray param to disable notifications in example |
116
|
|
|
$ret = $issueService->update($issueKey, $issueField, $editParams); |
117
|
|
|
|
118
|
|
|
var_dump($ret); |
|
|
|
|
119
|
|
|
} catch (SenhorVerdugoException $e) { |
|
|
|
|
120
|
|
|
$this->assertTrue(false, "update Failed : " . $e->getMessage()); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function project(ProjectModel $project) |
125
|
|
|
{ |
126
|
|
|
try { |
127
|
|
|
$p = new Project(); |
128
|
|
|
|
129
|
|
|
$p->setName('Updated Example') |
130
|
|
|
->setProjectTypeKey('software') |
131
|
|
|
->setProjectTemplateKey('com.atlassian.SenhorVerdugo-software-project-templates:SenhorVerdugo-software-project-management') |
132
|
|
|
->setDescription('Updated Example Project description') |
133
|
|
|
->setLead('new-leader') |
134
|
|
|
->setUrl('http://new.example.com') |
135
|
|
|
->setAssigneeType('UNASSIGNED'); |
136
|
|
|
|
137
|
|
|
$proj = new ProjectService(); |
138
|
|
|
|
139
|
|
|
$pj = $proj->updateProject($p, 'EX'); |
140
|
|
|
|
141
|
|
|
var_dump($pj); |
|
|
|
|
142
|
|
|
} catch (SenhorVerdugoException $e) { |
|
|
|
|
143
|
|
|
print("Error Occured! " . $e->getMessage()); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.