Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mantisbt/mantisbt
base: 1d0099704d6b
...
head fork: mantisbt/mantisbt
compare: 17793b94e17f
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 1 commit comment
  • 2 contributors
Commits on Jun 30, 2013
@winston01 winston01 New function added to retrieve bug history via API.
Fixes #9936: add history information

Signed-off-by: Laszlo Kovacs <winston01@freemail.hu>
Signed-off-by: Robert Munteanu <robert@lmn.ro>
f65336c
@rombert rombert soap api: add tests for the mc_issue_get_history call
Affects #9936: add history information
17793b9
View
37 api/soap/mantisconnect.wsdl
@@ -165,6 +165,25 @@
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
+ <xsd:complexType name="HistoryData">
+ <xsd:all>
+ <xsd:element name="date" type="xsd:integer"/>
+ <xsd:element name="userid" type="xsd:integer"/>
+ <xsd:element name="username" type="xsd:string"/>
+ <xsd:element name="field" type="xsd:string"/>
+ <xsd:element name="type" type="xsd:integer"/>
+ <xsd:element name="old_value" type="xsd:string"/>
+ <xsd:element name="new_value" type="xsd:string"
+ />
+ </xsd:all>
+ </xsd:complexType>
+ <xsd:complexType name="HistoryDataArray">
+ <xsd:complexContent>
+ <xsd:restriction base="SOAP-ENC:Array">
+ <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:HistoryData[]"/>
+ </xsd:restriction>
+ </xsd:complexContent>
+ </xsd:complexType>
<xsd:complexType name="IssueHeaderData">
<xsd:all>
<xsd:element name="id" type="xsd:integer"/>
@@ -436,6 +455,12 @@
<part name="issue_id" type="xsd:integer" /></message>
<message name="mc_issue_getResponse">
<part name="return" type="tns:IssueData" /></message>
+<message name="mc_issue_get_historyRequest">
+ <part name="username" type="xsd:string" />
+ <part name="password" type="xsd:string" />
+ <part name="issue_id" type="xsd:integer" /></message>
+<message name="mc_issue_get_historyResponse">
+ <part name="return" type="tns:HistoryDataArray" /></message>
<message name="mc_issue_get_biggest_idRequest">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
@@ -854,6 +879,11 @@
<input message="tns:mc_issue_getRequest"/>
<output message="tns:mc_issue_getResponse"/>
</operation>
+ <operation name="mc_issue_get_history">
+ <documentation>Get the history of the issue with the specified id.</documentation>
+ <input message="tns:mc_issue_get_historyRequest"/>
+ <output message="tns:mc_issue_get_historyResponse"/>
+ </operation>
<operation name="mc_issue_get_biggest_id">
<documentation>Get the latest submitted issue in the specified project.</documentation>
<input message="tns:mc_issue_get_biggest_idRequest"/>
@@ -1187,6 +1217,11 @@
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
<output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
</operation>
+ <operation name="mc_issue_get_history">
+ <soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issue_get_history" style="rpc"/>
+ <input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
+ <output><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
+ </operation>
<operation name="mc_issue_get_biggest_id">
<soap:operation soapAction="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php/mc_issue_get_biggest_id" style="rpc"/>
<input><soap:body use="encoded" namespace="http://futureware.biz/mantisconnect" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
@@ -1438,4 +1473,4 @@
<soap:address location="http://www.mantisbt.org/bugs/api/soap/mantisconnect.php"/>
</port>
</service>
-</definitions>
+</definitions>
View
42 api/soap/mc_issue_api.php
@@ -122,6 +122,48 @@ function mc_issue_get( $p_username, $p_password, $p_issue_id ) {
}
/**
+* Get history details about an issue.
+*
+* @param string $p_username The name of the user trying to access the issue.
+* @param string $p_password The password of the user.
+* @param integer $p_issue_id The id of the issue to retrieve.
+* @return Array that represents a HistoryDataArray structure
+*/
+function mc_issue_get_history( $p_username, $p_password, $p_issue_id ) {
+ global $g_project_override;
+
+ $t_user_id = mci_check_login( $p_username, $p_password );
+ if( $t_user_id === false ) {
+ return mci_soap_fault_login_failed();
+ }
+
+ $t_lang = mci_get_user_lang( $t_user_id );
+
+ if( !bug_exists( $p_issue_id ) ) {
+ return SoapObjectsFactory::newSoapFault('Client', 'Issue does not exist');
+ }
+
+ $t_project_id = bug_get_field( $p_issue_id, 'project_id' );
+ if( !mci_has_readonly_access( $t_user_id, $t_project_id ) ) {
+ return mci_soap_fault_access_denied( $t_user_id );
+ }
+ $g_project_override = $t_project_id;
+
+ if( !access_has_bug_level( VIEWER, $p_issue_id, $t_user_id ) ){
+ return mci_soap_fault_access_denied( $t_user_id );
+ }
+
+ $t_user_access_level = user_get_access_level( $t_user_id, $t_project_id );
+ if( !access_compare_level( $t_user_access_level, config_get( 'view_history_threshold' ) ) ){
+ return mci_soap_fault_access_denied( $t_user_id );
+ }
+
+ $t_bug_history = history_get_raw_events_array($p_issue_id, $t_user_id);
+
+ return $t_bug_history;
+}
+
+/**
* Returns the category name, possibly null if no category is assigned
*
* @param int $p_category_id
View
1  tests/soap/AllTests.php
@@ -31,6 +31,7 @@
require_once 'IssueMonitorTest.php';
require_once 'IssueNoteTest.php';
require_once 'IssueUpdateTest.php';
+require_once 'IssueHistoryTest.php';
require_once 'FilterTest.php';
require_once 'AttachmentTest.php';
require_once 'LoginTest.php';
View
115 tests/soap/IssueHistoryTest.php
@@ -0,0 +1,115 @@
+<?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 - 2013 MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+require_once 'SoapBase.php';
+
+/**
+ * Test fixture for issue history
+ */
+class IssueHistoryTest extends SoapBase {
+ /**
+ * A test case that tests the following:
+ * 1. Creates a new issue
+ * 2. validates that history entry is present
+ */
+ public function testCreatedIssueHasHistoryEntry() {
+
+ $issueToAdd = $this->getIssueToAdd( 'IssueHistoryTest.testCreatedIssueHasHistoryEntry' );
+
+ $issueId = $this->client->mc_issue_add(
+ $this->userName,
+ $this->password,
+ $issueToAdd);
+
+ $this->deleteAfterRun( $issueId );
+
+ $issueHistory = $this->client->mc_issue_get_history( $this->userName, $this->password, $issueId );
+
+ $this->assertEquals(1, count($issueHistory) );
+ // validate the format of the initial history entry
+ $historyData = $issueHistory[0];
+
+ $this->assertNotEmpty($historyData->date);
+
+ $this->assertEquals($this->userId, $historyData->userid);
+ $this->assertEquals($this->userName, $historyData->username);
+
+ $this->assertEquals(1, $historyData->type);
+
+ $this->assertEmpty($historyData->field);
+ $this->assertEmpty($historyData->old_value);
+ $this->assertEmpty($historyData->new_value);
+ }
+
+ /**
+ * A test case that tests the following:
+ * 1. Creates a new issue
+ * 2. Updates the issue summary
+ * 3. Validates that a history entry for the update was created
+ */
+ public function testUpdatedIssueHasHistoryEntry() {
+
+ $issueToAdd = $this->getIssueToAdd( 'IssueHistoryTest.testUpdatedIssueHasHistoryEntry' );
+
+ $issueId = $this->client->mc_issue_add(
+ $this->userName,
+ $this->password,
+ $issueToAdd);
+
+ $this->deleteAfterRun( $issueId );
+
+ $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);
+
+ $issueHistory = $this->client->mc_issue_get_history( $this->userName, $this->password, $issueId );
+
+ $this->assertEquals(2, count($issueHistory) );
+
+ // validate the format of the history entry following the update
+ $historyData = $issueHistory[1];
+
+ $this->assertNotEmpty($historyData->date);
+
+ $this->assertEquals($this->userId, $historyData->userid);
+ $this->assertEquals($this->userName, $historyData->username);
+
+ $this->assertEquals(0, $historyData->type);
+
+ $this->assertEquals('summary', $historyData->field);
+ $this->assertEquals($issueToAdd['summary'], $historyData->old_value);
+ $this->assertEquals($t_summary_update, $historyData->new_value);
+ }
+}

Showing you all comments on commits in this comparison.

@atrol
Collaborator

can be removed, $t_lang is not used

Something went wrong with that request. Please try again.