Skip to content

Commit 7716098

Browse files
authored
Merge pull request #178 from TheKvist/176-get-time-tracking
Adds method to get time stats for an issue to Issues API - refs #176
2 parents d8736df + 78e5f31 commit 7716098

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
@@ -191,4 +191,21 @@ protected function getApiClass()
191191
{
192192
return 'Gitlab\Api\Issues';
193193
}
194+
195+
/**
196+
* @test
197+
*/
198+
public function shouldGetIssueTimeStats()
199+
{
200+
$expectedArray = array('time_estimate' => 14400, 'total_time_spent' => 5400, 'human_time_estimate' => '4h', 'human_total_time_spent' => '1h 30m');
201+
202+
$api = $this->getApiMock();
203+
$api->expects($this->once())
204+
->method('get')
205+
->with('projects/1/issues/2/time_stats')
206+
->will($this->returnValue($expectedArray))
207+
;
208+
209+
$this->assertEquals($expectedArray, $api->getTimeStats(1, 2));
210+
}
194211
}

0 commit comments

Comments
 (0)