@@ -312,6 +312,86 @@ public function testGetIssueTypes()
312
312
$ this ->assertEquals ($ expected , $ actual );
313
313
}
314
314
315
+ /**
316
+ * @param string|integer $time_spent Time spent.
317
+ * @param array $expected_rest_params Expected rest params.
318
+ *
319
+ * @return void
320
+ * @dataProvider addWorkLogWithoutCustomParamsDataProvider
321
+ */
322
+ public function testAddWorkLogWithoutCustomParams ($ time_spent , array $ expected_rest_params )
323
+ {
324
+ $ response = '{} ' ;
325
+
326
+ $ this ->expectClientCall (
327
+ Api::REQUEST_POST ,
328
+ '/rest/api/2/issue/JRA-15/worklog ' ,
329
+ $ expected_rest_params ,
330
+ $ response
331
+ );
332
+
333
+ $ actual = $ this ->api ->addWorklog ('JRA-15 ' , $ time_spent );
334
+
335
+ $ this ->assertEquals (json_decode ($ response , true ), $ actual , 'The response is json-decoded. ' );
336
+ }
337
+
338
+ public static function addWorkLogWithoutCustomParamsDataProvider ()
339
+ {
340
+ return array (
341
+ 'integer time spent ' => array (12 , array ('timeSpentSeconds ' => 12 )),
342
+ 'string time spent ' => array ('12m ' , array ('timeSpent ' => '12m ' )),
343
+ );
344
+ }
345
+
346
+ public function testAddWorklogWithCustomParams ()
347
+ {
348
+ $ response = '{} ' ;
349
+
350
+ $ started = date (Api::DATE_TIME_FORMAT , 1621026000 );
351
+ $ this ->expectClientCall (
352
+ Api::REQUEST_POST ,
353
+ '/rest/api/2/issue/JRA-15/worklog ' ,
354
+ array ('timeSpent ' => '12m ' , 'started ' => $ started ),
355
+ $ response
356
+ );
357
+
358
+ $ actual = $ this ->api ->addWorklog ('JRA-15 ' , '12m ' , array ('started ' => $ started ));
359
+
360
+ $ this ->assertEquals (json_decode ($ response , true ), $ actual , 'The response is json-decoded. ' );
361
+ }
362
+
363
+ public function testDeleteWorkLogWithoutCustomParams ()
364
+ {
365
+ $ response = '{} ' ;
366
+
367
+ $ this ->expectClientCall (
368
+ Api::REQUEST_DELETE ,
369
+ '/rest/api/2/issue/JRA-15/worklog/11256 ' ,
370
+ array (),
371
+ $ response
372
+ );
373
+
374
+ $ actual = $ this ->api ->deleteWorklog ('JRA-15 ' , 11256 );
375
+
376
+ $ this ->assertEquals (json_decode ($ response , true ), $ actual , 'The response is json-decoded. ' );
377
+ }
378
+
379
+ public function testDeleteWorkLogWithCustomParams ()
380
+ {
381
+ $ response = '{} ' ;
382
+
383
+ $ this ->expectClientCall (
384
+ Api::REQUEST_DELETE ,
385
+ '/rest/api/2/issue/JRA-15/worklog/11256 ' ,
386
+ array ('custom ' => 'param ' ),
387
+ $ response
388
+ );
389
+
390
+ $ actual = $ this ->api ->deleteWorklog ('JRA-15 ' , 11256 , array ('custom ' => 'param ' ));
391
+
392
+ $ this ->assertEquals (json_decode ($ response , true ), $ actual , 'The response is json-decoded. ' );
393
+ }
394
+
315
395
/**
316
396
* Expects a particular client call.
317
397
*
0 commit comments