From: <gi...@ma...> - 2011-02-13 14:13:47
|
The branch, master-1.2.x has been updated via 83af863fa12943efb37fa95630ecd4c9cb8952a2 (commit) via 875c408dde8ed43e27ef5a473297f578b2d2ed8d (commit) via fff800a1c64a34b28e3c5eed8cc45119db64c2f5 (commit) via 12982280bd7699d6bf3a7cf4c11bc3a5a13c9bce (commit) via 0435ef642ff8fef52009e6bb763715dd6a6026e9 (commit) via ca18f1b9641dcdc3286fa6746e4b4281910a042e (commit) via 1cce8593558bd67b5d8519cce2c4b96a89815c14 (commit) via f4cfc077ab38aa0bb22db96f046c0ee583efb0b5 (commit) from 3b5c18e5eaa9ee793797949e33578a87f0355ce7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 83af863fa12943efb37fa95630ecd4c9cb8952a2 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:57:52 2011 +0200 Final tweaks to mci_issue_set_monitors Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit 875c408dde8ed43e27ef5a473297f578b2d2ed8d Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:54:55 2011 +0200 Add a test to verify that the monitor list is not changed on empty update Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit fff800a1c64a34b28e3c5eed8cc45119db64c2f5 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:53:40 2011 +0200 Implement removal of issue monitors on issue update Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit 12982280bd7699d6bf3a7cf4c11bc3a5a13c9bce Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:40:30 2011 +0200 Implement setting monitors on issue update Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit 0435ef642ff8fef52009e6bb763715dd6a6026e9 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:36:23 2011 +0200 Implement setting the monitors on issue creation Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit ca18f1b9641dcdc3286fa6746e4b4281910a042e Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:16:09 2011 +0200 Add the IssueMonitorTest to AllTests Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit 1cce8593558bd67b5d8519cce2c4b96a89815c14 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:07:04 2011 +0200 All the ability to retrive monitors using mc_issue_get Bug: 8558 ( SOAP API needs ability to Monitor a Task ) commit f4cfc077ab38aa0bb22db96f046c0ee583efb0b5 Author: Robert Munteanu <rob...@gm...> Date: Sat Feb 12 01:18:31 2011 +0200 Move the retrieval of bug monitors into the bug_api Bug: 8558 ( SOAP API needs ability to Monitor a Task ) ----------------------------------------------------------------------- Summary of changes: api/soap/mantisconnect.php | 3 +- api/soap/mc_account_api.php | 11 ++ api/soap/mc_issue_api.php | 60 ++++++++++++- bug_monitor_list_view_inc.php | 21 +---- core/bug_api.php | 35 +++++++ tests/soap/AllTests.php | 4 +- tests/soap/IssueMonitorTest.php | 200 +++++++++++++++++++++++++++++++++++++++ tests/soap/SoapBase.php | 2 + 8 files changed, 315 insertions(+), 21 deletions(-) create mode 100644 tests/soap/IssueMonitorTest.php ----------------------------------------------------------------------- commit 83af863fa12943efb37fa95630ecd4c9cb8952a2 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:57:52 2011 +0200 Final tweaks to mci_issue_set_monitors Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index a0501a7..6193f3e 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -327,7 +327,8 @@ function mci_issue_get_notes( $p_issue_id ) { /** * Sets the monitors of the specified issue * - * <p>This functions performs access level checks.</p> + * <p>This functions performs access level checks and only performs operations which would + * modify the existing monitors list.</p> * * @param int $p_issue_id the issue id to set the monitors for * @param int $p_user_id the user which requests the monitor change @@ -344,16 +345,13 @@ function mci_issue_set_monitors( $p_issue_id , $p_user_id, $p_monitors ) { foreach ( $t_monitors as $t_user_id ) { - $t_has_access; - if ( $p_user_id == $t_user_id ) { - $t_has_access = access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ); + if ( ! access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ) ) + continue; } else { - $t_has_access = access_has_bug_level( config_get( 'monitor_add_others_bug_threshold' ), $p_issue_id ); + if ( !access_has_bug_level( config_get( 'monitor_add_others_bug_threshold' ), $p_issue_id ) ) + continue; } - - if ( !$t_has_access ) - continue; if ( in_array( $p_user_id, $t_existing_monitors) ) continue; @@ -363,16 +361,13 @@ function mci_issue_set_monitors( $p_issue_id , $p_user_id, $p_monitors ) { foreach ( $t_existing_monitors as $t_user_id ) { - $t_has_access; - if ( $p_user_id == $t_user_id ) { - $t_has_access = access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ); + if ( ! access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ) ) + continue; } else { - $t_has_access = access_has_bug_level( config_get( 'monitor_remove_others_bug_threshold' ), $p_issue_id ); + if ( !access_has_bug_level( config_get( 'monitor_delete_others_bug_threshold' ), $p_issue_id ) ) + continue; } - - if ( !$t_has_access ) - continue; if ( in_array( $p_user_id, $t_monitors) ) continue; commit 875c408dde8ed43e27ef5a473297f578b2d2ed8d Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:54:55 2011 +0200 Add a test to verify that the monitor list is not changed on empty update Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/tests/soap/IssueMonitorTest.php b/tests/soap/IssueMonitorTest.php index a9c46f0..63536db 100644 --- a/tests/soap/IssueMonitorTest.php +++ b/tests/soap/IssueMonitorTest.php @@ -162,5 +162,39 @@ class IssueMonitorTest extends SoapBase { $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId); self::assertEquals(0, sizeof($issue->monitors)); - } + } + + /** + * A test case that tests the following + * + * 1. Creates a new issue with a monitor + * 2. Retrieves the issue + * 3. Updates the issue ( no actual changes ) + * 4. Retrieves the issue and verifies that the monitors list is unchanged + */ + public function testUpdateKeepsMonitor() { + + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testUpdateKeepsMonitor' ); + $issueToAdd['monitors'] = array( + array ('id' => $this->userId ) + ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $issue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue ); + + $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId); + + self::assertEquals(1, sizeof($issue->monitors)); + } } commit fff800a1c64a34b28e3c5eed8cc45119db64c2f5 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:53:40 2011 +0200 Implement removal of issue monitors on issue update Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index 28b984a..a0501a7 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -336,10 +336,14 @@ function mci_issue_get_notes( $p_issue_id ) { */ function mci_issue_set_monitors( $p_issue_id , $p_user_id, $p_monitors ) { - foreach ( $p_monitors as $t_monitor ) { - - $t_user_id = $t_monitor['id']; + $t_existing_monitors = bug_get_monitors( $p_issue_id ); + $t_monitors = array(); + foreach ( $p_monitors as $t_monitor ) + $t_monitors[] = $t_monitor['id']; + + foreach ( $t_monitors as $t_user_id ) { + $t_has_access; if ( $p_user_id == $t_user_id ) { @@ -351,8 +355,31 @@ function mci_issue_set_monitors( $p_issue_id , $p_user_id, $p_monitors ) { if ( !$t_has_access ) continue; - bug_monitor( $p_issue_id, $t_user_id ); + if ( in_array( $p_user_id, $t_existing_monitors) ) + continue; + + bug_monitor( $p_issue_id, $t_user_id); + } + + foreach ( $t_existing_monitors as $t_user_id ) { + + $t_has_access; + + if ( $p_user_id == $t_user_id ) { + $t_has_access = access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ); + } else { + $t_has_access = access_has_bug_level( config_get( 'monitor_remove_others_bug_threshold' ), $p_issue_id ); + } + + if ( !$t_has_access ) + continue; + + if ( in_array( $p_user_id, $t_monitors) ) + continue; + + bug_unmonitor( $p_issue_id, $t_user_id); } + } /** diff --git a/tests/soap/IssueMonitorTest.php b/tests/soap/IssueMonitorTest.php index 043b90c..a9c46f0 100644 --- a/tests/soap/IssueMonitorTest.php +++ b/tests/soap/IssueMonitorTest.php @@ -63,7 +63,7 @@ class IssueMonitorTest extends SoapBase { */ public function testAddMonitorWhenCreatingAnIssue() { - $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' ); + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddMonitorWhenCreatingAnIssue' ); $issueToAdd['monitors'] = array( array ('id' => $this->userId ) ); @@ -98,7 +98,7 @@ class IssueMonitorTest extends SoapBase { */ public function testAddMonitorToExistingIssue() { - $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' ); + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddMonitorToExistingIssue' ); $issueId = $this->client->mc_issue_add( $this->userName, @@ -127,4 +127,40 @@ class IssueMonitorTest extends SoapBase { self::assertEquals( $this->userId, $monitor->id ); self::assertEquals( $this->userName, $monitor->name ); } + + /** + * A test case that tests the following + * + * 1. Creates a new issue with a monitor + * 2. Retrieves the issue + * 3. Updates the monitor list to be empty + * 4. Retrieves the issue and verifies that the monitors list is empty + */ + public function testRemoveMonitor() { + + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' ); + $issueToAdd['monitors'] = array( + array ('id' => $this->userId ) + ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $issue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + $issue->monitors = array(); + + $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue ); + + $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId); + + self::assertEquals(0, sizeof($issue->monitors)); + } } commit 12982280bd7699d6bf3a7cf4c11bc3a5a13c9bce Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:40:30 2011 +0200 Implement setting monitors on issue update Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index 8a3d186..28b984a 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -803,6 +803,8 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) { $t_is_success = $t_bug_data->update( /* update_extended */ true, /* bypass_email */ true ); mci_issue_set_custom_fields( $p_issue_id, $p_issue['custom_fields'], true ); + if ( isset ( $p_issue['monitors'] ) ) + mci_issue_set_monitors( $p_issue_id , $t_user_id, $p_issue['monitors'] ); if ( isset( $p_issue['notes'] ) && is_array( $p_issue['notes'] ) ) { foreach ( $p_issue['notes'] as $t_note ) { diff --git a/tests/soap/IssueMonitorTest.php b/tests/soap/IssueMonitorTest.php index cd3093d..043b90c 100644 --- a/tests/soap/IssueMonitorTest.php +++ b/tests/soap/IssueMonitorTest.php @@ -88,4 +88,43 @@ class IssueMonitorTest extends SoapBase { self::assertEquals( $this->userName, $monitor->name ); } + + /** + * A test case that tests the following + * + * 1. Creates a new issue + * 2. Adds a monitor to it + * 3. Retrieves the issue and verifies that the user is in the monitor list + */ + public function testAddMonitorToExistingIssue() { + + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $issue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + $issue->monitors = array( + array ('id' => $this->userId ) + ); + + $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue ); + + $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId); + + self::assertEquals(1, sizeof($issue->monitors)); + + $monitor = $issue->monitors[0]; + + self::assertEquals( $this->userId, $monitor->id ); + self::assertEquals( $this->userName, $monitor->name ); + } } commit 0435ef642ff8fef52009e6bb763715dd6a6026e9 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:36:23 2011 +0200 Implement setting the monitors on issue creation Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index a13a9f8..8a3d186 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -325,6 +325,37 @@ function mci_issue_get_notes( $p_issue_id ) { } /** + * Sets the monitors of the specified issue + * + * <p>This functions performs access level checks.</p> + * + * @param int $p_issue_id the issue id to set the monitors for + * @param int $p_user_id the user which requests the monitor change + * @param array $p_monitors An array of arrays with the <em>id</em> field set to the id + * of the users which should monitor this issue. + */ +function mci_issue_set_monitors( $p_issue_id , $p_user_id, $p_monitors ) { + + foreach ( $p_monitors as $t_monitor ) { + + $t_user_id = $t_monitor['id']; + + $t_has_access; + + if ( $p_user_id == $t_user_id ) { + $t_has_access = access_has_bug_level( config_get( 'monitor_bug_threshold' ), $p_issue_id ); + } else { + $t_has_access = access_has_bug_level( config_get( 'monitor_add_others_bug_threshold' ), $p_issue_id ); + } + + if ( !$t_has_access ) + continue; + + bug_monitor( $p_issue_id, $t_user_id ); + } +} + +/** * Get the biggest issue id currently used. * * @param string $p_username The name of the user trying to retrieve the information @@ -579,7 +610,7 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { if( access_has_project_level( config_get( 'roadmap_update_threshold' ), $t_bug_data->project_id, $t_user_id ) ) { $t_bug_data->target_version = isset( $p_issue['target_version'] ) ? $p_issue['target_version'] : ''; } - + # omitted: # var $bug_text_id # $t_bug_data->profile_id; @@ -592,6 +623,8 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { $t_issue_id = $t_bug_data->create(); mci_issue_set_custom_fields( $t_issue_id, $p_issue['custom_fields'], false ); + if ( isset ( $p_issue['monitors'] ) ) + mci_issue_set_monitors( $t_issue_id , $t_user_id, $p_issue['monitors'] ); if( isset( $t_notes ) && is_array( $t_notes ) ) { foreach( $t_notes as $t_note ) { diff --git a/tests/soap/IssueMonitorTest.php b/tests/soap/IssueMonitorTest.php index 9e11b9d..cd3093d 100644 --- a/tests/soap/IssueMonitorTest.php +++ b/tests/soap/IssueMonitorTest.php @@ -51,4 +51,41 @@ class IssueMonitorTest extends SoapBase { // no monitors on new issue $this->assertEquals(0, sizeof($issue->monitors)); } + + /** + * A test case that tests the following + * + * 1. Creates a new issue + * 2. Adds a monitor to it + * 3. Retrieves the issue and verifies that the user is in the monitor list + * 4. Removes a monitor from the issue + * 5. Retrieves the issue and verifies that the user is not in the monitor list + */ + public function testAddMonitorWhenCreatingAnIssue() { + + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' ); + $issueToAdd['monitors'] = array( + array ('id' => $this->userId ) + ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $issue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + self::assertEquals(1, sizeof($issue->monitors)); + + $monitor = $issue->monitors[0]; + + self::assertEquals( $this->userId, $monitor->id ); + self::assertEquals( $this->userName, $monitor->name ); + + } } diff --git a/tests/soap/SoapBase.php b/tests/soap/SoapBase.php index 4f78436..b99d3b9 100644 --- a/tests/soap/SoapBase.php +++ b/tests/soap/SoapBase.php @@ -33,6 +33,8 @@ class SoapBase extends PHPUnit_Framework_TestCase { protected $client; protected $userName = 'administrator'; protected $password = 'root'; + protected $userId = '1'; + protected $mantisPath; private $issueIdsToDelete = array(); private $versionIdsToDelete = array(); commit ca18f1b9641dcdc3286fa6746e4b4281910a042e Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:16:09 2011 +0200 Add the IssueMonitorTest to AllTests Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/tests/soap/AllTests.php b/tests/soap/AllTests.php index 0986b8e..eec7b47 100644 --- a/tests/soap/AllTests.php +++ b/tests/soap/AllTests.php @@ -28,6 +28,7 @@ require_once dirname(__FILE__) . '/../TestConfig.php'; require_once 'EnumTest.php'; require_once 'IssueAddTest.php'; +require_once 'IssueMonitorTest.php'; require_once 'IssueNoteTest.php'; require_once 'IssueUpdateTest.php'; require_once 'FilterTest.php'; @@ -61,6 +62,7 @@ class Soap_AllTests extends PHPUnit_Framework_TestSuite $suite->addTestSuite('EnumTest'); $suite->addTestSuite('IssueAddTest'); + $suite->addTestSuite('IssueMonitorTest'); $suite->addTestSuite('IssueNoteTest'); $suite->addTestSuite('IssueUpdateTest'); $suite->addTestSuite('FilterTest'); @@ -68,7 +70,7 @@ class Soap_AllTests extends PHPUnit_Framework_TestSuite $suite->addTestSuite('LoginTest'); $suite->addTestSuite('CategoryTest'); $suite->addTestSuite('CompressionTest'); - $suite->addTestSuite('ProjectTest'); + $suite->addTestSuite('ProjectTest'); return $suite; } commit 1cce8593558bd67b5d8519cce2c4b96a89815c14 Author: Robert Munteanu <rob...@gm...> Date: Sun Feb 13 15:07:04 2011 +0200 All the ability to retrive monitors using mc_issue_get Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/api/soap/mantisconnect.php b/api/soap/mantisconnect.php index d5143eb..49ab571 100644 --- a/api/soap/mantisconnect.php +++ b/api/soap/mantisconnect.php @@ -283,7 +283,8 @@ $l_oServer->wsdl->addComplexType( 'relationships' => array( 'name' => 'relationships', 'type' => 'tns:RelationshipDataArray', 'minOccurs' => '0' ), 'notes' => array( 'name' => 'notes', 'type' => 'tns:IssueNoteDataArray', 'minOccurs' => '0' ), 'custom_fields' => array( 'name' => 'custom_fields', 'type' => 'tns:CustomFieldValueForIssueDataArray', 'minOccurs' => '0' ), - 'due_date' => array( 'name' => 'due_date', 'type' => 'xsd:dateTime', 'minOccurs' => '0' ) + 'due_date' => array( 'name' => 'due_date', 'type' => 'xsd:dateTime', 'minOccurs' => '0' ), + 'monitors' => array( 'name' => 'monitors', 'type' => 'AccountDataArray', 'minOccurs' => '0') ) ); diff --git a/api/soap/mc_account_api.php b/api/soap/mc_account_api.php index da96206..cc41cc7 100644 --- a/api/soap/mc_account_api.php +++ b/api/soap/mc_account_api.php @@ -26,3 +26,14 @@ function mci_account_get_array_by_id( $p_user_id ) { } return $t_result; } + +function mci_account_get_array_by_ids ( $p_user_ids ) { + + $t_result = array(); + + foreach ( $p_user_ids as $t_user_id ) { + $t_result[] = mci_account_get_array_by_id( $t_user_id ); + } + + return $t_result; +} diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index ea364b8..a13a9f8 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -110,6 +110,7 @@ function mc_issue_get( $p_username, $p_password, $p_issue_id ) { $t_issue_data['relationships'] = mci_issue_get_relationships( $p_issue_id, $t_user_id ); $t_issue_data['notes'] = mci_issue_get_notes( $p_issue_id ); $t_issue_data['custom_fields'] = mci_issue_get_custom_fields( $p_issue_id ); + $t_issue_data['monitors'] = mci_account_get_array_by_ids( bug_get_monitors ( $p_issue_id ) ); return $t_issue_data; } diff --git a/tests/soap/IssueMonitorTest.php b/tests/soap/IssueMonitorTest.php new file mode 100644 index 0000000..9e11b9d --- /dev/null +++ b/tests/soap/IssueMonitorTest.php @@ -0,0 +1,54 @@ +<?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 - 2011 MantisBT Team - man...@li... + * @link http://www.mantisbt.org + */ + +require_once 'SoapBase.php'; + +/** + * Test fixture for issue monitoring webservice methods. + */ +class IssueMonitorTest extends SoapBase { + /** + * A test case that tests the following: + * 1. Creates a new issue + * 2. validates that the monitor list is empty + */ + public function testCreateIssueHasEmptyMonitorList() { + + $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testCreateIssueHasEmptyMonitorList' ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $issue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + // no monitors on new issue + $this->assertEquals(0, sizeof($issue->monitors)); + } +} commit f4cfc077ab38aa0bb22db96f046c0ee583efb0b5 Author: Robert Munteanu <rob...@gm...> Date: Sat Feb 12 01:18:31 2011 +0200 Move the retrieval of bug monitors into the bug_api Bug: 8558 ( SOAP API needs ability to Monitor a Task ) diff --git a/bug_monitor_list_view_inc.php b/bug_monitor_list_view_inc.php index c872ea3..039847d 100644 --- a/bug_monitor_list_view_inc.php +++ b/bug_monitor_list_view_inc.php @@ -25,24 +25,9 @@ */ if ( access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $f_bug_id ) ) { - $c_bug_id = db_prepare_int( $f_bug_id ); - $t_bug_monitor_table = db_get_table( 'mantis_bug_monitor_table' ); - $t_user_table = db_get_table( 'mantis_user_table' ); - - # get the bugnote data - $query = "SELECT user_id, enabled - FROM $t_bug_monitor_table m, $t_user_table u - WHERE m.bug_id=" . db_param() . " AND m.user_id = u.id - ORDER BY u.realname, u.username"; - $result = db_query_bound($query, Array( $c_bug_id ) ); - $num_users = db_num_rows($result); - - $t_users = array(); - for ( $i = 0; $i < $num_users; $i++ ) { - $row = db_fetch_array( $result ); - $t_users[$i] = $row['user_id']; - } - user_cache_array_rows( $t_users ); + + $t_users = bug_get_monitors( $f_bug_id ); + $num_users = sizeof ( $t_users ); echo '<a name="monitors" id="monitors" /><br />'; diff --git a/core/bug_api.php b/core/bug_api.php index e92921b..9bbd30e 100644 --- a/core/bug_api.php +++ b/core/bug_api.php @@ -1764,6 +1764,41 @@ function bug_monitor( $p_bug_id, $p_user_id ) { } /** + * Returns the list of users monitoring the specified bug + * + * @param int $p_bug_id + */ +function bug_get_monitors( $p_bug_id ) { + + if ( ! access_has_bug_level( config_get( 'show_monitor_list_threshold' ), $p_bug_id ) ) { + return Array(); + } + + + $c_bug_id = db_prepare_int( $p_bug_id ); + $t_bug_monitor_table = db_get_table( 'mantis_bug_monitor_table' ); + $t_user_table = db_get_table( 'mantis_user_table' ); + + # get the bugnote data + $query = "SELECT user_id, enabled + FROM $t_bug_monitor_table m, $t_user_table u + WHERE m.bug_id=" . db_param() . " AND m.user_id = u.id + ORDER BY u.realname, u.username"; + $result = db_query_bound($query, Array( $c_bug_id ) ); + $num_users = db_num_rows($result); + + $t_users = array(); + for ( $i = 0; $i < $num_users; $i++ ) { + $row = db_fetch_array( $result ); + $t_users[$i] = $row['user_id']; + } + + user_cache_array_rows( $t_users ); + + return $t_users; +} + +/** * Copy list of users monitoring a bug to the monitor list of a second bug * @param int p_source_bug_id integer representing the bug ID of the source bug * @param int p_dest_bug_id integer representing the bug ID of the destination bug ----------------------------------------------------------------------- -- Mantis Bug Tracker |