Skip to content

Commit

Permalink
Implement setting monitors on issue update
Browse files Browse the repository at this point in the history
Bug: 8558 ( SOAP API needs ability to Monitor a Task )
  • Loading branch information
rombert committed Feb 13, 2011
1 parent d0454a1 commit f6a79e3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/soap/mc_issue_api.php
Expand Up @@ -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 ) {
Expand Down
39 changes: 39 additions & 0 deletions tests/soap/IssueMonitorTest.php
Expand Up @@ -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 );
}
}

0 comments on commit f6a79e3

Please sign in to comment.