Skip to content

Commit

Permalink
Allow mc_project_get_{issues,issue_headers} to work with ALL_PROJECTS
Browse files Browse the repository at this point in the history
Fixes #13526: It is not possible to retrieve issues for 'All Projects'
  • Loading branch information
rombert committed Dec 6, 2011
1 parent f58911e commit ecf3eb7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/soap/mc_project_api.php
Expand Up @@ -14,7 +14,7 @@ function mc_project_get_issues( $p_username, $p_password, $p_project_id, $p_page

$t_lang = mci_get_user_lang( $t_user_id );

if( !project_exists( $p_project_id ) ) {
if( $p_project_id != ALL_PROJECTS && !project_exists( $p_project_id ) ) {
return new soap_fault( 'Client', '', "Project '$p_project_id' does not exist." );
}

Expand Down Expand Up @@ -854,7 +854,7 @@ function mc_project_get_issue_headers( $p_username, $p_password, $p_project_id,
if( $t_user_id === false ) {
return mci_soap_fault_login_failed();
}
if( !project_exists( $p_project_id ) ) {
if( $p_project_id != ALL_PROJECTS && !project_exists( $p_project_id ) ) {
return new soap_fault( 'Client', '', "Project '$p_project_id' does not exist." );
}

Expand Down
65 changes: 65 additions & 0 deletions tests/soap/FilterTest.php
Expand Up @@ -235,6 +235,43 @@ public function testGetIssuesPaged() {
$this->doTestGetPages('mc_project_get_issues');
}

public function testGetAllProjectsIssues() {

$initialIssues = $this->getAllProjectsIssues();

$issueToAdd = $this->getIssueToAdd( 'FilterTest.testGetAllProjectsIssues' );

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

$this->deleteAfterRun( $issueId );

$projectIssues = $this->getAllProjectsIssues();

$this->assertEquals( 1, count( $projectIssues ) - count( $initialIssues ), "count(projectIssues) - count(initialIssues)");
$this->assertEquals( $issueId, $projectIssues[0]->id, "issueId");
}

public function testGetAllProjectsIssueHeaders() {

$initialIssues = $this->getAllProjectsIssueHeaders();

$issueToAdd = $this->getIssueToAdd( 'FilterTest.testGetProjectIssueHeaders' );

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

$this->deleteAfterRun( $issueId );

$projectIssues = $this->getAllProjectsIssueHeaders();

$this->assertEquals( 1, count( $projectIssues ) - count( $initialIssues ), "count(projectIssues) - count(initialIssues)" );
$this->assertEquals( $issueId, $projectIssues[0]->id, "issueId" );
}

/**
*
Expand All @@ -249,6 +286,20 @@ private function getProjectIssues() {
0,
self::ISSUES_TO_RETRIEVE);
}

/**
*
* @return Array the project issues
*/
private function getAllProjectsIssues() {

return $this->client->mc_project_get_issues(
$this->userName,
$this->password,
0,
0,
self::ISSUES_TO_RETRIEVE);
}

/**
*
Expand All @@ -263,4 +314,18 @@ private function getProjectIssueHeaders() {
0,
self::ISSUES_TO_RETRIEVE);
}

/**
*
* @return Array the project issues
*/
private function getAllProjectsIssueHeaders() {

return $this->client->mc_project_get_issue_headers(
$this->userName,
$this->password,
0,
0,
self::ISSUES_TO_RETRIEVE);
}
}

0 comments on commit ecf3eb7

Please sign in to comment.