Skip to content

Commit

Permalink
Fixes #11427: Undefined index: id
Browse files Browse the repository at this point in the history
Fix provided by vboctor, supplemented with a SOAP test.
  • Loading branch information
rombert committed Feb 26, 2010
1 parent db07af1 commit 44be8f3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
8 changes: 3 additions & 5 deletions api/soap/mc_api.php
Expand Up @@ -101,12 +101,10 @@ function mci_get_project_view_state_id( $p_view_state ) {
function mci_get_user_id( $p_user ) {
$t_user_id = 0;

if( (int) $p_user['id'] != 0 ) {
if ( isset( $p_user['id'] ) && (int) $p_user['id'] != 0 ) {
$t_user_id = (int) $p_user['id'];
} else {
if( isset( $p_user['name'] ) ) {
$t_user_id = user_get_id_by_name( $p_user['name'] );
}
} elseif ( isset( $p_user['name'] ) ) {
$t_user_id = user_get_id_by_name( $p_user['name'] );
}

return $t_user_id;
Expand Down
27 changes: 27 additions & 0 deletions tests/soap/IssueAddTest.php
Expand Up @@ -355,4 +355,31 @@ public function testCreateIssueWithTimeTrackingNote() {
$this->password,
$issueId);
}

/**
* This issue tests the following
*
* 1. Creating an issue where the handler is given by name
* 2. Retrieving the issue
* 3. Verifying that the handler name is correctly set
*/
public function testCreateIssueWithHandlerByName() {

$issueToAdd = $this->getIssueToAdd( 'testCreateIssueWithHandlerByName' );
$issueToAdd['handler'] = array(
'name' => $this->userName
);

$issueId = $this->client->mc_issue_add(
$this->userName,
$this->password,
$issueToAdd);

$issue = $this->client->mc_issue_get(
$this->userName,
$this->password,
$issueId);

$this->assertEquals( $this->userName, $issue->handler->name );
}
}

0 comments on commit 44be8f3

Please sign in to comment.