From 2f3d72cfc04e3d8642d3a5b26b23a012d74d70a8 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 15 May 2013 21:42:15 +1200 Subject: [PATCH] CRM-12545 fix tests broken by work on activity contact restructuring --- api/v3/Activity.php | 17 ++++++++++--- api/v3/examples/ActivityCreate.php | 36 ++++++++++++++------------- tests/phpunit/api/v3/ActivityTest.php | 1 + 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 32a6ae3ac4..ed5de2c3b7 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -187,14 +187,23 @@ function _civicrm_api3_activity_create_spec(&$params) { 'name' => 'assignee_id', 'title' => 'assigned to', 'type' => 1, - 'FKClassName' => 'CRM_Activity_DAO_ActivityAssignment', + 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', ); $params['target_contact_id'] = array( 'name' => 'target_id', 'title' => 'Activity Target', 'type' => 1, - 'FKClassName' => 'CRM_Activity_DAO_ActivityTarget', + 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', ); + + $params['source_contact_id'] = array( + 'name' => 'source_contact_id', + 'title' => 'Activity Source Contact', + 'type' => 1, + 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', + 'api.default' => 'user_contact_id', + ); + $params['activity_status_id'] = array( 'name' => 'status_id', 'title' => 'Status Id', @@ -240,7 +249,7 @@ function civicrm_api3_activity_get($params) { $returns[$returnkey] = $v; } } - + $returns['source_contact_id'] = 1; foreach ($returns as $n => $v) { switch ($n) { case 'assignee_contact_id': @@ -273,6 +282,8 @@ function civicrm_api3_activity_get($params) { return civicrm_api3_create_success($activities, $params, 'activity', 'get'); } + + /** * Delete a specified Activity. * diff --git a/api/v3/examples/ActivityCreate.php b/api/v3/examples/ActivityCreate.php index 474388b18c..a0f0666eb0 100644 --- a/api/v3/examples/ActivityCreate.php +++ b/api/v3/examples/ActivityCreate.php @@ -1,14 +1,12 @@ 17, - 'activity_type_id' => 40, + 'activity_type_id' => '44', 'subject' => 'test activity type id', 'activity_date_time' => '2011-06-02 14:36:13', 'status_id' => 2, @@ -20,7 +18,6 @@ $params = array( 'custom_1' => 'custom string', ); - require_once 'api/api.php'; $result = civicrm_api( 'activity','create',$params ); return $result; @@ -38,19 +35,18 @@ function activity_create_expectedresult(){ 'id' => 1, 'values' => array( '1' => array( - 'id' => 1, - 'source_contact_id' => 17, + 'id' => '1', 'source_record_id' => '', - 'activity_type_id' => 40, + 'activity_type_id' => '44', 'subject' => 'test activity type id', 'activity_date_time' => '20110602143613', - 'duration' => 120, + 'duration' => '120', 'location' => 'Pensulvania', 'phone_id' => '', 'phone_number' => '', 'details' => 'a test activity', - 'status_id' => 2, - 'priority_id' => 1, + 'status_id' => '2', + 'priority_id' => '1', 'parent_id' => '', 'is_test' => '', 'medium_id' => '', @@ -71,18 +67,24 @@ function activity_create_expectedresult(){ } - - /* * This example has been generated from the API test suite. The test that created it is called -* -* testActivityCreateCustom and can be found in -* http://svn.civicrm.org/civicrm/branches/v3.4/tests/phpunit/CiviTest/api/v3/ActivityTest.php -* -* You can see the outcome of the API tests at +* +* testActivityCreateCustom and can be found in +* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php +* +* You can see the outcome of the API tests at * http://tests.dev.civicrm.org/trunk/results-api_v3 +* +* To Learn about the API read +* http://book.civicrm.org/developer/current/techniques/api/ +* * and review the wiki at * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs +* * Read more about testing here * http://wiki.civicrm.org/confluence/display/CRM/Testing +* +* API Standards documentation: +* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards */ \ No newline at end of file diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 0bd2d0c6d5..20f6e0345b 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -504,6 +504,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $params = $this->_params; $params['custom_' . $ids['custom_field_id']] = "custom string"; $result = civicrm_api($this->_entity, 'create', $params); + $this->documentMe($params, $result, __FUNCTION__, __FILE__); $this->assertAPISuccess($result, ' in line ' . __LINE__); $result = civicrm_api($this->_entity, 'get', array('return.custom_' . $ids['custom_field_id'] => 1, 'version' => 3, 'id' => $result['id'])); $this->assertEquals("custom string", $result['values'][$result['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); -- 2.25.1