Skip to content

Commit

Permalink
Use config_get to retrieve the path to MantisBT
Browse files Browse the repository at this point in the history
This approach seems to work, and is backed by a PHPUnit test.

Fixes# 12262: Mylyn-Mantis 3.1.4 attach a context error
  • Loading branch information
rombert committed Feb 7, 2011
1 parent bde76f1 commit 44bb795
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
14 changes: 3 additions & 11 deletions api/soap/mc_api.php
Expand Up @@ -165,21 +165,13 @@ function mci_null_if_empty( $p_value ) {
}

/**
* Gets the url for MantisBT. This is based on the 'path' config variable in MantisBT. However,
* the default value for 'path' does not work properly when access from within MantisConnect.
* This internal function fixes this bug.
* Gets the url for MantisBT.
*
* @return MantisBT URL terminated by a /.
*/
function mci_get_mantis_path() {
$t_path = config_get( 'path' );
$t_dir = basename( dirname( __FILE__ ) );

# for some reason str_replace() doesn't work when DIRECTORY_SEPARATOR (/) is in the search
# string.
$t_path = str_replace( $t_dir . '/', '', $t_path );

return $t_path;

return config_get( 'path' );
}

# Given a enum string and num, return the appropriate localized string
Expand Down
1 change: 1 addition & 0 deletions tests/soap/AttachmentTest.php
Expand Up @@ -73,6 +73,7 @@ public function testAttachmentIsAdded() {

$this->assertEquals( 1, count( $issue->attachments ), 'count($issue->attachments)' );
$this->assertEquals( $attachmentContents, base64_decode( $attachment ), '$attachmentContents' );
$this->assertEquals( $this->mantisPath.'file_download.php?file_id='.$issue->attachments[0]->id.'&type=bug', $issue->attachments[0]->download_url);
}


Expand Down
3 changes: 3 additions & 0 deletions tests/soap/SoapBase.php
Expand Up @@ -33,6 +33,7 @@ class SoapBase extends PHPUnit_Framework_TestCase {
protected $client;
protected $userName = 'administrator';
protected $password = 'root';
protected $mantisPath;
private $issueIdsToDelete = array();
private $versionIdsToDelete = array();
private $defaultSoapClientOptions = array( 'trace' => true,
Expand All @@ -54,6 +55,8 @@ protected function setUp()
array_merge($this->defaultSoapClientOptions, $this->extraSoapClientFlags()
)
);

$this->mantisPath = substr($GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'], 0, -strlen('api/soap/mantisconnect.php?wsdl'));
}

/**
Expand Down

0 comments on commit 44bb795

Please sign in to comment.