@@ -458,4 +458,54 @@ public function testUpdateWithRareFields() {
458
458
$ this ->assertEquals ( 'os ' , $ retrievedIssue ->os );
459
459
$ this ->assertEquals ( 'os_build ' , $ retrievedIssue ->os_build );
460
460
}
461
+
462
+ public function testUpdateWithTagOperations () {
463
+
464
+ // initialise tags
465
+ $ tagId1 = $ this ->client ->mc_tag_add ( $ this ->userName , $ this ->password , array (
466
+ 'name ' => 'IssueUpdateTest.testUpdateWithTagAdditions '
467
+ ));
468
+ $ this ->deleteTagAfterRun ( $ tagId1 );
469
+
470
+ $ tagId2 = $ this ->client ->mc_tag_add ( $ this ->userName , $ this ->password , array (
471
+ 'name ' => 'IssueUpdateTest.testUpdateWithTagAdditions2 '
472
+ ));
473
+ $ this ->deleteTagAfterRun ( $ tagId2 );
474
+
475
+ $ tag1 = new stdClass ();
476
+ $ tag1 ->id = $ tagId1 ;
477
+
478
+ $ tag2 = new stdClass ();
479
+ $ tag2 ->id = $ tagId2 ;
480
+
481
+ // create issue
482
+ $ issueToAdd = $ this ->getIssueToAdd ( 'IssueUpdateTest.testUpdateWithRareFields ' );
483
+ $ issueId = $ this ->client ->mc_issue_add ( $ this ->userName , $ this ->password , $ issueToAdd );
484
+ $ this ->deleteAfterRun ( $ issueId );
485
+ $ issue = $ this ->client ->mc_issue_get ( $ this ->userName , $ this ->password , $ issueId );
486
+
487
+ // update from 0 to 2 tags -> test attaching tags
488
+ $ issue ->tags = array ( $ tag1 , $ tag2 );
489
+ $ this ->client ->mc_issue_update ( $ this ->userName , $ this ->password , $ issueId , $ issue );
490
+ $ issue = $ this ->client ->mc_issue_get ( $ this ->userName , $ this ->password , $ issueId );
491
+ self ::assertEquals (2 , count ( $ issue ->tags ) );
492
+
493
+ // update from 2 to 1 tags -> test partially detaching tags
494
+ $ issue ->tags = array ( $ tag1 );
495
+ $ this ->client ->mc_issue_update ( $ this ->userName , $ this ->password , $ issueId , $ issue );
496
+ $ issue = $ this ->client ->mc_issue_get ( $ this ->userName , $ this ->password , $ issueId );
497
+ self ::assertEquals (1 , count ( $ issue ->tags ) );
498
+
499
+ // update from 1 to 2 tags -> test partially attaching tags
500
+ $ issue ->tags = array ( $ tag1 , $ tag2 );
501
+ $ this ->client ->mc_issue_update ( $ this ->userName , $ this ->password , $ issueId , $ issue );
502
+ $ issue = $ this ->client ->mc_issue_get ( $ this ->userName , $ this ->password , $ issueId );
503
+ self ::assertEquals (2 , count ( $ issue ->tags ) );
504
+
505
+ // update from 2 to 0 tags -> test detaching tags
506
+ $ issue ->tags = array ();
507
+ $ this ->client ->mc_issue_update ( $ this ->userName , $ this ->password , $ issueId , $ issue );
508
+ $ issue = $ this ->client ->mc_issue_get ( $ this ->userName , $ this ->password , $ issueId );
509
+ self ::assertEquals (0 , count ( $ issue ->tags ) );
510
+ }
461
511
}
0 commit comments