From 44bb795de8d67ac2897fd8665177ead0b56c7d0d Mon Sep 17 00:00:00 2001 From: Robert Munteanu Date: Tue, 8 Feb 2011 01:12:59 +0200 Subject: [PATCH] Use config_get to retrieve the path to MantisBT This approach seems to work, and is backed by a PHPUnit test. Fixes# 12262: Mylyn-Mantis 3.1.4 attach a context error --- api/soap/mc_api.php | 14 +++----------- tests/soap/AttachmentTest.php | 1 + tests/soap/SoapBase.php | 3 +++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/api/soap/mc_api.php b/api/soap/mc_api.php index 57b8398c56..16139c2d68 100644 --- a/api/soap/mc_api.php +++ b/api/soap/mc_api.php @@ -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 diff --git a/tests/soap/AttachmentTest.php b/tests/soap/AttachmentTest.php index 461227e0fd..59a6339e35 100644 --- a/tests/soap/AttachmentTest.php +++ b/tests/soap/AttachmentTest.php @@ -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); } diff --git a/tests/soap/SoapBase.php b/tests/soap/SoapBase.php index f99a8381aa..4f78436ab0 100644 --- a/tests/soap/SoapBase.php +++ b/tests/soap/SoapBase.php @@ -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, @@ -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')); } /**