Skip to content

Commit 0c482d8

Browse files
author
Olaf Hoffmann
committed
Adds method to get time stats for an issue to Issues API - refs #176
1 parent d8736df commit 0c482d8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/Gitlab/Api/Issues.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,14 @@ public function removeComment($project_id, $issue_id, $note_id)
126126
{
127127
return $this->delete($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_id).'/notes/'.$this->encodePath($note_id)));
128128
}
129+
130+
/**
131+
* @param int $project_id
132+
* @param int $issue_iid
133+
* @return mixed
134+
*/
135+
public function getTimeStats($project_id, $issue_iid)
136+
{
137+
return $this->get($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid) .'/time_stats'));
138+
}
129139
}

test/Gitlab/Tests/Api/IssuesTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,23 @@ public function shouldGetIssueComment()
152152
$this->assertEquals($expectedArray, $api->showComment(1, 2, 3));
153153
}
154154

155+
/**
156+
* @test
157+
*/
158+
public function shouldGetIssueTimeStats()
159+
{
160+
$expectedArray = array('time_estimate' => 14400, 'total_time_spent' => 5400, 'human_time_estimate' => '4h', 'human_total_time_spent' => '1h 30m');
161+
162+
$api = $this->getApiMock();
163+
$api->expects($this->once())
164+
->method('get')
165+
->with('projects/1/issues/2/time_stats')
166+
->will($this->returnValue($expectedArray))
167+
;
168+
169+
$this->assertEquals($expectedArray, $api->getTimeStats(1, 2));
170+
}
171+
155172
/**
156173
* @test
157174
*/

0 commit comments

Comments
 (0)