diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index 6081e34688..1536deae14 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -803,6 +803,8 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) { $t_is_success = $t_bug_data->update( /* update_extended */ true, /* bypass_email */ true ); mci_issue_set_custom_fields( $p_issue_id, $p_issue['custom_fields'], true ); + if ( isset ( $p_issue['monitors'] ) ) + mci_issue_set_monitors( $p_issue_id , $t_user_id, $p_issue['monitors'] ); if ( isset( $p_issue['notes'] ) && is_array( $p_issue['notes'] ) ) { foreach ( $p_issue['notes'] as $t_note ) { diff --git a/tests/soap/IssueMonitorTest.php b/tests/soap/IssueMonitorTest.php index cd3093d548..043b90c915 100644 --- a/tests/soap/IssueMonitorTest.php +++ b/tests/soap/IssueMonitorTest.php @@ -88,4 +88,43 @@ public function testAddMonitorWhenCreatingAnIssue() { self::assertEquals( $this->userName, $monitor->name ); } + + /** + * A test case that tests the following + * + * 1. Creates a new issue + * 2. Adds a monitor to it + * 3. Retrieves the issue and verifies that the user is in the monitor list + */ + public function testAddMonitorToExistingIssue() { + + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $issue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + $issue->monitors = array( + array ('id' => $this->userId ) + ); + + $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue ); + + $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId); + + self::assertEquals(1, sizeof($issue->monitors)); + + $monitor = $issue->monitors[0]; + + self::assertEquals( $this->userId, $monitor->id ); + self::assertEquals( $this->userName, $monitor->name ); + } }