@@ -187,9 +187,72 @@ public function shouldUpdateComment()
187187 $ this ->assertEquals ($ expectedArray , $ api ->updateComment (1 , 2 , 3 , 'An edited comment ' ));
188188 }
189189
190- protected function getApiClass ()
190+ /**
191+ * @test
192+ */
193+ public function shouldSetTimeEstimate ()
191194 {
192- return 'Gitlab\Api\Issues ' ;
195+ $ expectedArray = array ('time_estimate ' => 14400 , 'total_time_spent ' => 0 , 'human_time_estimate ' => '4h ' , 'human_total_time_spent ' => null );
196+
197+ $ api = $ this ->getApiMock ();
198+ $ api ->expects ($ this ->once ())
199+ ->method ('post ' )
200+ ->with ('projects/1/issues/2/time_estimate ' , array ('duration ' => '4h ' ))
201+ ->will ($ this ->returnValue ($ expectedArray ))
202+ ;
203+
204+ $ this ->assertEquals ($ expectedArray , $ api ->setTimeEstimate (1 , 2 , '4h ' ));
205+ }
206+
207+ /**
208+ * @test
209+ */
210+ public function shouldResetTimeEstimate ()
211+ {
212+ $ expectedArray = array ('time_estimate ' => 0 , 'total_time_spent ' => 0 , 'human_time_estimate ' => null , 'human_total_time_spent ' => null );
213+
214+ $ api = $ this ->getApiMock ();
215+ $ api ->expects ($ this ->once ())
216+ ->method ('post ' )
217+ ->with ('projects/1/issues/2/reset_time_estimate ' )
218+ ->will ($ this ->returnValue ($ expectedArray ))
219+ ;
220+
221+ $ this ->assertEquals ($ expectedArray , $ api ->resetTimeEstimate (1 , 2 ));
222+ }
223+
224+ /**
225+ * @test
226+ */
227+ public function shouldAddSpentTime ()
228+ {
229+ $ expectedArray = array ('time_estimate ' => 0 , 'total_time_spent ' => 14400 , 'human_time_estimate ' => null , 'human_total_time_spent ' => '4h ' );
230+
231+ $ api = $ this ->getApiMock ();
232+ $ api ->expects ($ this ->once ())
233+ ->method ('post ' )
234+ ->with ('projects/1/issues/2/add_spent_time ' , array ('duration ' => '4h ' ))
235+ ->will ($ this ->returnValue ($ expectedArray ))
236+ ;
237+
238+ $ this ->assertEquals ($ expectedArray , $ api ->addSpentTime (1 , 2 , '4h ' ));
239+ }
240+
241+ /**
242+ * @test
243+ */
244+ public function shouldResetSpentTime ()
245+ {
246+ $ expectedArray = array ('time_estimate ' => 0 , 'total_time_spent ' => 0 , 'human_time_estimate ' => null , 'human_total_time_spent ' => null );
247+
248+ $ api = $ this ->getApiMock ();
249+ $ api ->expects ($ this ->once ())
250+ ->method ('post ' )
251+ ->with ('projects/1/issues/2/reset_spent_time ' )
252+ ->will ($ this ->returnValue ($ expectedArray ))
253+ ;
254+
255+ $ this ->assertEquals ($ expectedArray , $ api ->resetSpentTime (1 , 2 ));
193256 }
194257
195258 /**
@@ -208,4 +271,9 @@ public function shouldGetIssueTimeStats()
208271
209272 $ this ->assertEquals ($ expectedArray , $ api ->getTimeStats (1 , 2 ));
210273 }
274+
275+ protected function getApiClass ()
276+ {
277+ return 'Gitlab\Api\Issues ' ;
278+ }
211279}
0 commit comments