Skip to content

Commit

Permalink
Fixed #9102: webservice api call causes SYSTEM NOTICEs --- fixed for …
Browse files Browse the repository at this point in the history
…mc_issue_update().
  • Loading branch information
vboctor committed Apr 13, 2009
1 parent 04f398c commit ffff385
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 12 deletions.
19 changes: 7 additions & 12 deletions api/soap/mc_issue_api.php
Expand Up @@ -592,11 +592,6 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
$t_project = $p_issue['project'];
$t_summary = $p_issue['summary'];
$t_description = $p_issue['description'];
$t_custom_fields = $p_issue['custom_fields'];

$v_fixed_in_version = $p_issue['fixed_in_version'];
$v_version = $p_issue['version'];
$v_target_version = $p_issue['target_version'];

if( $t_reporter_id == 0 ) {
$t_reporter_id = $t_user_id;
Expand Down Expand Up @@ -627,14 +622,14 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
}
}

if( isset( $v_version ) && !is_blank( $v_version ) && !version_get_id( $v_version, $t_project_id ) ) {
if ( isset( $p_issue['version'] ) && !is_blank( $p_issue['version'] ) && !version_get_id( $p_issue['version'], $t_project_id ) ) {
$t_error_when_version_not_found = config_get( 'mc_error_when_version_not_found' );
if( $t_error_when_version_not_found == ON ) {
$t_project_name = project_get_name( $t_project_id );
return new soap_fault( 'Client', '', "Version '$v_version' does not exist in project '$t_project_name'." );
return new soap_fault( 'Client', '', "Version '" . $p_issue['version'] . "' does not exist in project '$t_project_name'." );
} else {
$t_version_when_not_found = config_get( 'mc_version_when_not_found' );
$v_version = $t_version_when_not_found;
$p_issue['version'] = $t_version_when_not_found;
}
}

Expand Down Expand Up @@ -679,9 +674,9 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
$t_bug_data->os = isset( $v_os ) ? $v_os : '';
$t_bug_data->os_build = isset( $v_os_build ) ? $v_os_build : '';
$t_bug_data->platform = isset( $v_platform ) ? $v_platform : '';
$t_bug_data->version = isset( $v_version ) ? $v_version : '';
$t_bug_data->fixed_in_version = isset( $v_fixed_in_version ) ? $v_fixed_in_version : '';
$t_bug_data->target_version = isset( $v_target_version ) ? $v_target_version : '';
$t_bug_data->version = isset( $p_issue['version'] ) ? $p_issue['version'] : '';
$t_bug_data->fixed_in_version = isset( $p_issue['fixed_in_version'] ) ? $p_issue['fixed_in_version'] : '';
$t_bug_data->target_version = isset( $p_issue['target_version'] ) ? $p_issue['target_version'] : '';
$t_bug_data->build = isset( $v_build ) ? $v_build : '';
$t_bug_data->view_state = $t_view_state_id;
$t_bug_data->summary = $t_summary;
Expand All @@ -699,7 +694,7 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) {
# submit the issue
$t_is_success = bug_update( $p_issue_id, $t_bug_data, true, false );

mci_issue_set_custom_fields( $p_issue_id, $t_custom_fields );
mci_issue_set_custom_fields( $p_issue_id, $p_issue['custom_fields'] );

if( isset( $v_notes ) && is_array( $v_notes ) ) {
foreach( $v_notes as $t_note ) {
Expand Down
162 changes: 162 additions & 0 deletions tests/soap/IssueUpdateTest.php
@@ -0,0 +1,162 @@
<?php
# MantisBT - a php based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.

/**
* @package Tests
* @subpackage UnitTests
* @copyright Copyright (C) 2002 - 2009 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/

require_once 'SoapBase.php';

/**
* Test fixture for issue update webservice methods.
*/
class IssueUpdateTest extends SoapBase {
/**
* A test case that tests the following:
* 1. Ability to create an issue with only the mandatory parameters.
* 2. Ability to retrieve the issue just added.
* 3. Ability to modify the summary of the retrieved issue and update it in MantisBT.
* 4. Ability to delete the issue.
*/
public function testUpdateSummaryBasedOnPreviousGet() {
$issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateSummary' );

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

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

$t_summary_update = $issueToAdd['summary'] . ' - updated';

$issueToUpdate = $createdIssue;
$issueToUpdate->summary = $t_summary_update;

$this->client->mc_issue_update(
$this->userName,
$this->password,
$issueId,
$issueToUpdate);

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

$issue = $updatedIssue;

// explicitly specified fields
$this->assertEquals( $issueToAdd['category'], $issue->category );
$this->assertEquals( $t_summary_update, $issue->summary );
$this->assertEquals( $issueToAdd['description'], $issue->description );
$this->assertEquals( $issueToAdd['project']['id'], $issue->project->id );

// defaulted fields
$this->assertEquals( $issueId, $issue->id );
$this->assertEquals( 10, $issue->view_state->id );
$this->assertEquals( 'public', $issue->view_state->name );
$this->assertEquals( 30, $issue->priority->id );
$this->assertEquals( 'normal', $issue->priority->name );
$this->assertEquals( 50, $issue->severity->id );
$this->assertEquals( 'minor', $issue->severity->name );
$this->assertEquals( 10, $issue->status->id );
$this->assertEquals( 'new', $issue->status->name );
$this->assertEquals( $this->userName, $issue->reporter->name );
$this->assertEquals( 70, $issue->reproducibility->id );
$this->assertEquals( 'have not tried', $issue->reproducibility->name );
$this->assertEquals( 0, $issue->sponsorship_total );
$this->assertEquals( 10, $issue->projection->id );
$this->assertEquals( 'none', $issue->projection->name );
$this->assertEquals( 10, $issue->eta->id );
$this->assertEquals( 'none', $issue->eta->name );
$this->assertEquals( 10, $issue->resolution->id );
$this->assertEquals( 'open', $issue->resolution->name );

$this->client->mc_issue_delete(
$this->userName,
$this->password,
$issueId);
}

/**
* A test case that tests the following:
* 1. Ability to create an issue with only the mandatory parameters.
* 2. Ability to update the summary of the issue while only supplying the mandatory fields.
* 3. Ability to delete the issue.
*/
public function testUpdateSummaryBasedOnMandatoryFields() {
$issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateSummaryBasedOnMandatoryFields' );

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

$issueToUpdate = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateSummaryBasedOnMandatoryFields' );

$this->client->mc_issue_update(
$this->userName,
$this->password,
$issueId,
$issueToUpdate);

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

$issue = $updatedIssue;

// explicitly specified fields
$this->assertEquals( $issueToUpdate['category'], $issue->category );
$this->assertEquals( $issueToUpdate['summary'], $issue->summary );
$this->assertEquals( $issueToUpdate['description'], $issue->description );
$this->assertEquals( $issueToUpdate['project']['id'], $issue->project->id );

// defaulted fields
$this->assertEquals( $issueId, $issue->id );
$this->assertEquals( 10, $issue->view_state->id );
$this->assertEquals( 'public', $issue->view_state->name );
$this->assertEquals( 30, $issue->priority->id );
$this->assertEquals( 'normal', $issue->priority->name );
$this->assertEquals( 50, $issue->severity->id );
$this->assertEquals( 'minor', $issue->severity->name );
$this->assertEquals( 10, $issue->status->id );
$this->assertEquals( 'new', $issue->status->name );
$this->assertEquals( $this->userName, $issue->reporter->name );
$this->assertEquals( 70, $issue->reproducibility->id );
$this->assertEquals( 'have not tried', $issue->reproducibility->name );
$this->assertEquals( 0, $issue->sponsorship_total );
$this->assertEquals( 10, $issue->projection->id );
$this->assertEquals( 'none', $issue->projection->name );
$this->assertEquals( 10, $issue->eta->id );
$this->assertEquals( 'none', $issue->eta->name );
$this->assertEquals( 10, $issue->resolution->id );
$this->assertEquals( 'open', $issue->resolution->name );

$this->client->mc_issue_delete(
$this->userName,
$this->password,
$issueId);
}
}

0 comments on commit ffff385

Please sign in to comment.