From: <gi...@ma...> - 2009-10-30 11:07:06
|
The branch, master has been updated via 29d7063423458b93cd2fadac44a80ad8d128e0cf (commit) from 26ac6758bda77a08f2f9ee7a19858bc69424637c (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 29d7063423458b93cd2fadac44a80ad8d128e0cf Author: Robert Munteanu <rob...@gm...> Date: Wed Oct 28 18:18:48 2009 +0200 Fixes #11015: mc_issue_update erases 'Due date' field The due_date field has been added to the WSDL and is now exposed by mc_issue_get and accepted by mc_issue_add and mc_issue_update. Proper access checkes are in place. The due_date is read with the local time zone offset applied since nusoap seems to apply the offset wrong when parsing. Reference: http://www.nabble.com/NUSOAP-datetime-UTC-issue-td16627310.html Tests have been added for both adding and updating an issue, skipped if the thresholds don't allow the admin user to view and update the due date. ----------------------------------------------------------------------- Summary of changes: api/soap/mantisconnect.php | 3 +- api/soap/mc_issue_api.php | 40 ++++++++++++++++++++++++++++++++-- tests/soap/IssueAddTest.php | 33 ++++++++++++++++++++++++++++ tests/soap/IssueUpdateTest.php | 46 +++++++++++++++++++++++++++++++++++++++- tests/soap/SoapBase.php | 7 ++++++ 5 files changed, 124 insertions(+), 5 deletions(-) ----------------------------------------------------------------------- commit 29d7063423458b93cd2fadac44a80ad8d128e0cf Author: Robert Munteanu <rob...@gm...> Date: Wed Oct 28 18:18:48 2009 +0200 Fixes #11015: mc_issue_update erases 'Due date' field The due_date field has been added to the WSDL and is now exposed by mc_issue_get and accepted by mc_issue_add and mc_issue_update. Proper access checkes are in place. The due_date is read with the local time zone offset applied since nusoap seems to apply the offset wrong when parsing. Reference: http://www.nabble.com/NUSOAP-datetime-UTC-issue-td16627310.html Tests have been added for both adding and updating an issue, skipped if the thresholds don't allow the admin user to view and update the due date. diff --git a/api/soap/mantisconnect.php b/api/soap/mantisconnect.php index ca0f4cc..5f6a5d1 100644 --- a/api/soap/mantisconnect.php +++ b/api/soap/mantisconnect.php @@ -275,7 +275,8 @@ $l_oServer->wsdl->addComplexType( 'attachments' => array( 'name' => 'attachments', 'type' => 'tns:AttachmentDataArray', 'minOccurs' => '0' ), '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' ) + 'custom_fields' => array( 'name' => 'custom_fields', 'type' => 'tns:CustomFieldValueForIssueDataArray', 'minOccurs' => '0' ), + 'due_date' => array( 'name' => 'due_date', 'type' => 'xsd:dateTime', 'minOccurs' => '0' ) ) ); diff --git a/api/soap/mc_issue_api.php b/api/soap/mc_issue_api.php index a47643f..db23f69 100644 --- a/api/soap/mc_issue_api.php +++ b/api/soap/mc_issue_api.php @@ -104,7 +104,12 @@ 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 ); - + + if ( access_has_bug_level( config_get( 'due_date_view_threshold' ), $p_issue_id ) && !date_is_null( $t_bug->due_date ) ) { + $t_issue_data['due_date'] = timestamp_to_iso8601( $t_bug->due_date ); + } else { + $t_issue_data['due_date'] = ''; + } return $t_issue_data; } @@ -518,7 +523,12 @@ function mc_issue_add( $p_username, $p_password, $p_issue ) { $t_bug_data->view_state = $t_view_state_id; $t_bug_data->summary = $t_summary; $t_bug_data->sponsorship_total = isset( $p_issue['sponsorship_total'] ) ? $p_issue['sponsorship_total'] : 0; - $t_bug_data->due_date = date_get_null(); + + if ( isset( $p_issue['due_date'] ) && access_has_global_level( config_get( 'due_date_update_threshold' ) ) ) { + $t_bug_data->due_date = mci_iso8601_to_timestamp( $p_issue['due_date'] ); + } else { + $t_bug_data->due_date = date_get_null(); + } 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'] : ''; @@ -685,7 +695,12 @@ function mc_issue_update( $p_username, $p_password, $p_issue_id, $p_issue ) { $t_bug_data->view_state = $t_view_state_id; $t_bug_data->summary = $t_summary; $t_bug_data->sponsorship_total = isset( $v_sponsorship_total ) ? $v_sponsorship_total : 0; - $t_bug_data->due_date = date_get_null(); + + if ( isset( $p_issue['due_date'] ) && access_has_global_level( config_get( 'due_date_update_threshold' ) ) ) { + $t_bug_data->due_date = mci_iso8601_to_timestamp( $p_issue['due_date'] ); + } else { + $t_bug_data->due_date = date_get_null(); + } 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'] : ''; @@ -1015,3 +1030,22 @@ function mc_issue_checkin( $p_username, $p_password, $p_issue_id, $p_comment, $p return true; } + +/** + * Returns the date in iso8601 format, with proper timezone offset applied + * + * @param string $p_date the date in iso8601 format + * @return int the timestamp + */ +function mci_iso8601_to_timestamp( $p_date ) { + + // retrieve the offset, seems to be lost by nusoap + $t_utc_date = new DateTime( $p_date, new DateTimeZone( 'UTC' ) ); + $t_timezone = new DateTimeZone( date_default_timezone_get() ); + $t_offset = $t_timezone->getOffset( $t_utc_date ); + + $t_raw_timestamp = iso8601_to_timestamp( $p_date ); + + return $t_raw_timestamp - $t_offset; + +} diff --git a/tests/soap/IssueAddTest.php b/tests/soap/IssueAddTest.php index a75cdf9..7dfa62e 100644 --- a/tests/soap/IssueAddTest.php +++ b/tests/soap/IssueAddTest.php @@ -201,4 +201,37 @@ class IssueAddTest extends SoapBase { $this->assertEquals( $adminUser->id, $issue->handler->id, 'handler.id' ); } + + /** + * This issue tests the following + * + * 1. Creating an issue with a due date + * 2. Retrieving the issue + * 3. Validating that the due date is properly set + */ + public function testCreateIssueWithDueDate() { + + $this->skipIfDueDateIsNotEnabled(); + + $date = '2015-10-29T12:59:14Z'; + + $issueToAdd = $this->getIssueToAdd( 'IssueAddTest.testCreateIssueWithDueDate' ); + + $issueToAdd['due_date'] = $date; + + $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->assertEquals( $date, $issue->due_date, "due_date"); + } } diff --git a/tests/soap/IssueUpdateTest.php b/tests/soap/IssueUpdateTest.php index de301f4..8a0ba8a 100644 --- a/tests/soap/IssueUpdateTest.php +++ b/tests/soap/IssueUpdateTest.php @@ -248,7 +248,6 @@ class IssueUpdateTest extends SoapBase { $this->password, $issueToAdd); - $this->deleteAfterRun( $issueId ); $issue = $this->client->mc_issue_get( @@ -271,4 +270,49 @@ class IssueUpdateTest extends SoapBase { $this->assertEquals( $adminUser->id, $updatedIssue->handler->id, 'handler.id' ); } + + /** + * This issue tests the following + * + * 1. Creating an issue + * 2. Retrieving the issue + * 3. Updating the issue with a new date + * 4. Re-retrieving the issue + * 5. Validating the value of the due date + */ + public function testUpdateIssueDueDate() { + + $date = '2015-10-29T12:59:14Z'; + + $this->skipIfDueDateIsNotEnabled(); + + $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateIssueDueDate' ); + + $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->due_date = $date; + + $this->client->mc_issue_update( + $this->userName, + $this->password, + $issueId, + $issue); + + $updatedIssue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + + $this->assertEquals( $date, $updatedIssue->due_date, "due_date"); + } } diff --git a/tests/soap/SoapBase.php b/tests/soap/SoapBase.php index 7242081..0c3f2dc 100644 --- a/tests/soap/SoapBase.php +++ b/tests/soap/SoapBase.php @@ -90,4 +90,11 @@ class SoapBase extends PHPUnit_Framework_TestCase { $this->issueIdsToDelete[] = $issueId; } + protected function skipIfDueDateIsNotEnabled() { + + if ( $this->client->mc_config_get_string( $this->userName, $this->password, 'due_date_view_threshold' ) > 90 || + $this->client->mc_config_get_string( $this->userName, $this->password, 'due_date_update_threshold' ) > 90 ) { + $this->markTestSkipped('Due date thresholds are too high.'); + } + } } ----------------------------------------------------------------------- -- Mantis Bug Tracker |