From 7b1dc1f6ad701ecd73a3754cc03a52416a290d70 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 29 Mar 2017 20:23:02 +0530 Subject: [PATCH] CRM-19715, fixed api test so that its not affected by any deletion of activity types from core ---------------------------------------- * CRM-19715: Remove Close Accounting Period code https://issues.civicrm.org/jira/browse/CRM-19715 --- .../Activity/ContactRefCustomField.php | 4 +-- .../Activity/ContactRefCustomFieldGet.php | 2 +- api/v3/examples/Activity/Create.php | 4 +-- api/v3/examples/Activity/DateTimeHigh.php | 2 +- api/v3/examples/Activity/DateTimeLow.php | 2 +- api/v3/examples/Activity/Get.php | 19 ++++++++----- .../Activity/ReturnAssigneeContact.php | 3 ++- tests/phpunit/api/v3/ActivityTest.php | 27 ++++++++++--------- 8 files changed, 36 insertions(+), 27 deletions(-) diff --git a/api/v3/examples/Activity/ContactRefCustomField.php b/api/v3/examples/Activity/ContactRefCustomField.php index b830541308..b7e650b6e3 100644 --- a/api/v3/examples/Activity/ContactRefCustomField.php +++ b/api/v3/examples/Activity/ContactRefCustomField.php @@ -10,7 +10,7 @@ function activity_create_example() { $params = array( 'source_contact_id' => 1, - 'activity_type_id' => '55', + 'activity_type_id' => 'Test activity type', 'subject' => 'test activity type id', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 2, @@ -57,7 +57,7 @@ function activity_create_expectedresult() { '1' => array( 'id' => '1', 'source_record_id' => '', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'test activity type id', 'activity_date_time' => '20110602143613', 'duration' => '120', diff --git a/api/v3/examples/Activity/ContactRefCustomFieldGet.php b/api/v3/examples/Activity/ContactRefCustomFieldGet.php index 8603caf946..47e797e5b5 100644 --- a/api/v3/examples/Activity/ContactRefCustomFieldGet.php +++ b/api/v3/examples/Activity/ContactRefCustomFieldGet.php @@ -48,7 +48,7 @@ function activity_get_expectedresult() { 'values' => array( '1' => array( 'id' => '1', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'test activity type id', 'activity_date_time' => '2011-06-02 14:36:13', 'duration' => '120', diff --git a/api/v3/examples/Activity/Create.php b/api/v3/examples/Activity/Create.php index a380f128d0..0a3c1474f3 100644 --- a/api/v3/examples/Activity/Create.php +++ b/api/v3/examples/Activity/Create.php @@ -8,7 +8,7 @@ function activity_create_example() { $params = array( 'source_contact_id' => 1, - 'activity_type_id' => '55', + 'activity_type_id' => 'Test activity type', 'subject' => 'test activity type id', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 2, @@ -55,7 +55,7 @@ function activity_create_expectedresult() { '1' => array( 'id' => '1', 'source_record_id' => '', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'test activity type id', 'activity_date_time' => '20110602143613', 'duration' => '120', diff --git a/api/v3/examples/Activity/DateTimeHigh.php b/api/v3/examples/Activity/DateTimeHigh.php index 54d9ace232..b41659c205 100644 --- a/api/v3/examples/Activity/DateTimeHigh.php +++ b/api/v3/examples/Activity/DateTimeHigh.php @@ -49,7 +49,7 @@ function activity_get_expectedresult() { 'values' => array( '0' => array( 'id' => '1', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'Make-it-Happen Meeting', 'activity_date_time' => '2011-01-01 00:00:00', 'duration' => '120', diff --git a/api/v3/examples/Activity/DateTimeLow.php b/api/v3/examples/Activity/DateTimeLow.php index e670e377e2..dec83787de 100644 --- a/api/v3/examples/Activity/DateTimeLow.php +++ b/api/v3/examples/Activity/DateTimeLow.php @@ -48,7 +48,7 @@ function activity_get_expectedresult() { 'values' => array( '0' => array( 'id' => '2', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'Make-it-Happen Meeting', 'activity_date_time' => '2012-02-16 00:00:00', 'duration' => '120', diff --git a/api/v3/examples/Activity/Get.php b/api/v3/examples/Activity/Get.php index 1d98195589..9a208f9df1 100644 --- a/api/v3/examples/Activity/Get.php +++ b/api/v3/examples/Activity/Get.php @@ -8,7 +8,7 @@ function activity_get_example() { $params = array( 'contact_id' => 1, - 'activity_type_id' => '55', + 'activity_type_id' => 9999, 'sequential' => 1, 'return.custom_1' => 1, ); @@ -47,17 +47,24 @@ function activity_get_expectedresult() { 'id' => 1, 'values' => array( '0' => array( - 'source_contact_id' => '1', 'id' => '1', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'test activity type id', - 'location' => 'Pennsylvania', 'activity_date_time' => '2011-06-02 14:36:13', + 'duration' => '120', + 'location' => 'Pennsylvania', 'details' => 'a test activity', 'status_id' => '2', - 'activity_name' => 'Test activity type', - 'status' => 'Completed', + 'priority_id' => '1', + 'is_test' => 0, + 'is_auto' => 0, + 'is_current_revision' => '1', + 'is_deleted' => 0, + 'is_star' => 0, 'custom_1' => 'custom string', + 'source_contact_id' => '1', + 'status' => 'Completed', + 'activity_name' => 'Test activity type', 'custom_1_1' => 'custom string', ), ), diff --git a/api/v3/examples/Activity/ReturnAssigneeContact.php b/api/v3/examples/Activity/ReturnAssigneeContact.php index 4042c39fff..6c3464a113 100644 --- a/api/v3/examples/Activity/ReturnAssigneeContact.php +++ b/api/v3/examples/Activity/ReturnAssigneeContact.php @@ -52,7 +52,7 @@ function activity_get_expectedresult() { 'values' => array( '0' => array( 'id' => '1', - 'activity_type_id' => '55', + 'activity_type_id' => '9999', 'subject' => 'test activity type id', 'activity_date_time' => '2011-06-02 14:36:13', 'duration' => '120', @@ -134,6 +134,7 @@ function activity_get_expectedresult() { 'im' => '', 'worldregion_id' => '', 'world_region' => '', + 'languages' => 'English (United States)', 'individual_prefix' => 'Mr.', 'individual_suffix' => 'II', 'communication_style' => '', diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 5ce55f7c0f..414a6643d9 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -60,17 +60,18 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->_contactID = $this->individualCreate(); //create activity types + $this->test_activity_type_value = 9999; $activityTypes = $this->callAPISuccess('option_value', 'create', array( 'option_group_id' => 2, 'name' => 'Test activity type', 'label' => 'Test activity type', + 'value' => $this->test_activity_type_value, 'sequential' => 1, )); - $this->test_activity_type_value = $activityTypes['values'][0]['value']; $this->test_activity_type_id = $activityTypes['id']; $this->_params = array( 'source_contact_id' => $this->_contactID, - 'activity_type_id' => $this->test_activity_type_value, + 'activity_type_id' => 'Test activity type', 'subject' => 'test activity type id', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 2, @@ -401,16 +402,6 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->assertEquals($assignee['id'], $result['assignee_contact_id'][0]); } - /** - * Test civicrm_activity_create() using example code. - */ - public function testActivityCreateExample() { - require_once 'api/v3/examples/Activity/Create.php'; - $result = activity_create_example(); - $expectedResult = activity_create_expectedresult(); - $this->assertEquals($result, $expectedResult); - } - /** * Test civicrm_activity_create() with valid parameters and custom data. */ @@ -429,6 +420,16 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->customGroupDelete($ids['custom_group_id']); } + /** + * Test civicrm_activity_create() using example code. + */ + public function testActivityCreateExample() { + require_once 'api/v3/examples/Activity/Create.php'; + $result = activity_create_example(); + $expectedResult = activity_create_expectedresult(); + $this->assertEquals($result, $expectedResult); + } + /** * Test civicrm_activity_create() with valid parameters and custom data. */ @@ -1170,7 +1171,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $this->assertEquals(1, count($target), ' in line ' . __LINE__); $this->assertEquals(TRUE, in_array($contact3, $assignee), ' in line ' . __LINE__); $this->assertEquals(TRUE, in_array($contact4, $target), ' in line ' . __LINE__); - + $this->_params['activity_type_id'] = $this->test_activity_type_value; foreach ($this->_params as $fld => $val) { $this->assertEquals($val, $result['values'][$result['id']][$fld]); } -- 2.25.1