From a6ec24c401d2bc57d482fd9b0d00ac2a4f552108 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 9 Feb 2015 16:00:11 -0500 Subject: [PATCH] Add deprecation notice to generated examples --- api/v3/SurveyRespondant.php | 2 +- api/v3/examples/ActivityType/Create.php | 8 +++-- api/v3/examples/ActivityType/Get.php | 2 ++ api/v3/examples/Constant/Get.php | 46 +++++++++++++++++++----- api/v3/examples/SurveyRespondant/Get.php | 3 ++ tests/phpunit/api/v3/ConstantTest.php | 9 ++--- tests/templates/documentFunction.tpl | 7 ++++ 7 files changed, 59 insertions(+), 18 deletions(-) diff --git a/api/v3/SurveyRespondant.php b/api/v3/SurveyRespondant.php index e834e2b1de..5ed5772afe 100644 --- a/api/v3/SurveyRespondant.php +++ b/api/v3/SurveyRespondant.php @@ -77,7 +77,7 @@ function civicrm_api3_survey_respondant_get(&$params) { $respondants = CRM_Campaign_BAO_Survey::getSurveyActivities($surveyID, $interviewerID, $statusIds); - return (civicrm_api3_create_success($respondants, $params)); + return (civicrm_api3_create_success($respondants, $params, 'SurveyRespondant', 'get')); } /** diff --git a/api/v3/examples/ActivityType/Create.php b/api/v3/examples/ActivityType/Create.php index 9879a89f88..be4265deec 100644 --- a/api/v3/examples/ActivityType/Create.php +++ b/api/v3/examples/ActivityType/Create.php @@ -2,6 +2,8 @@ /** * Test Generated example of using activity_type create API. * + * @deprecated + * The activity_type api is deprecated. Please use the option_value api instead. * * @return array * API result array @@ -46,10 +48,10 @@ function activity_type_create_expectedresult() { 'is_error' => 0, 'version' => 3, 'count' => 1, - 'id' => 780, + 'id' => 784, 'values' => array( - '780' => array( - 'id' => '780', + '784' => array( + 'id' => '784', 'option_group_id' => '2', 'label' => 'send out letters', 'value' => '51', diff --git a/api/v3/examples/ActivityType/Get.php b/api/v3/examples/ActivityType/Get.php index eddcaaf0a8..f914ae5b94 100644 --- a/api/v3/examples/ActivityType/Get.php +++ b/api/v3/examples/ActivityType/Get.php @@ -2,6 +2,8 @@ /** * Test Generated example of using activity_type get API. * + * @deprecated + * The activity_type api is deprecated. Please use the option_value api instead. * * @return array * API result array diff --git a/api/v3/examples/Constant/Get.php b/api/v3/examples/Constant/Get.php index 72e004bc12..96250780e5 100644 --- a/api/v3/examples/Constant/Get.php +++ b/api/v3/examples/Constant/Get.php @@ -2,13 +2,15 @@ /** * Test Generated example of using constant get API. * + * @deprecated + * The constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead. * * @return array * API result array */ function constant_get_example() { $params = array( - 'field' => 'location_type_id', + 'name' => 'activityType', ); try{ @@ -40,14 +42,42 @@ function constant_get_expectedresult() { $expectedResult = array( 'is_error' => 0, 'version' => 3, - 'count' => 5, + 'count' => 32, 'values' => array( - '5' => 'Billing', - '1' => 'Home', - '3' => 'Main', - '4' => 'Other', - '2' => 'Work', + '1' => 'Meeting', + '2' => 'Phone Call', + '3' => 'Email', + '4' => 'Outbound SMS', + '5' => 'Event Registration', + '6' => 'Contribution', + '7' => 'Membership Signup', + '8' => 'Membership Renewal', + '9' => 'Tell a Friend', + '10' => 'Pledge Acknowledgment', + '11' => 'Pledge Reminder', + '12' => 'Inbound Email', + '17' => 'Membership Renewal Reminder', + '19' => 'Bulk Email', + '22' => 'Print PDF Letter', + '34' => 'Mass SMS', + '35' => 'Change Membership Status', + '36' => 'Change Membership Type', + '37' => 'Cancel Recurring Contribution', + '38' => 'Update Recurring Contribution Billing Details', + '39' => 'Update Recurring Contribution', + '40' => 'Reminder Sent', + '41' => 'Export Accounting Batch', + '42' => 'Create Batch', + '43' => 'Edit Batch', + '44' => 'SMS delivery', + '45' => 'Inbound SMS', + '46' => 'Payment', + '47' => 'Refund', + '48' => 'Change Registration', + '49' => 'Downloaded Invoice', + '50' => 'Emailed Invoice', ), + 'deprecated' => 'The constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.', ); return $expectedResult; @@ -56,7 +86,7 @@ function constant_get_expectedresult() { /** * This example has been generated from the API test suite. * The test that created it is called -* testLocationTypeGet +* testActivityType * and can be found in * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php * diff --git a/api/v3/examples/SurveyRespondant/Get.php b/api/v3/examples/SurveyRespondant/Get.php index eaec444247..4f89c96afa 100644 --- a/api/v3/examples/SurveyRespondant/Get.php +++ b/api/v3/examples/SurveyRespondant/Get.php @@ -2,6 +2,8 @@ /** * Test Generated example of using survey_respondant get API. * + * @deprecated + * The survey_respondant api is not currently supported. * * @return array * API result array @@ -43,6 +45,7 @@ function survey_respondant_get_expectedresult() { 'version' => 3, 'count' => 0, 'values' => array(), + 'deprecated' => 'The survey_respondant api is not currently supported.', ); return $expectedResult; diff --git a/tests/phpunit/api/v3/ConstantTest.php b/tests/phpunit/api/v3/ConstantTest.php index c805368cbd..85ed7ff58f 100644 --- a/tests/phpunit/api/v3/ConstantTest.php +++ b/tests/phpunit/api/v3/ConstantTest.php @@ -84,12 +84,9 @@ class api_v3_ConstantTest extends CiviUnitTestCase { * Test civicrm_constant_get( 'activityType' ) */ public function testActivityType() { - - $parameters = array(TRUE, FALSE, TRUE); - - $result = $this->callAPISuccess('constant', 'get', array( + $result = $this->callAPIAndDocument('constant', 'get', array( 'name' => 'activityType', - )); + ), __FUNCTION__, __FILE__, NULL, NULL, 'get'); $this->assertTrue($result['count'] > 2, "In line " . __LINE__); $this->assertContains('Meeting', $result['values'], "In line " . __LINE__); } @@ -104,7 +101,7 @@ class api_v3_ConstantTest extends CiviUnitTestCase { $params = array( 'field' => 'location_type_id', ); - $result = $this->callAPIAndDocument('address', 'getoptions', $params, __FUNCTION__, __FILE__); + $result = $this->callAPISuccess('address', 'getoptions', $params); $this->assertTrue($result['count'] > 3, "In line " . __LINE__); $this->assertContains('Home', $result['values'], "In line " . __LINE__); $this->assertContains('Work', $result['values'], "In line " . __LINE__); diff --git a/tests/templates/documentFunction.tpl b/tests/templates/documentFunction.tpl index f1c9a1b6a6..36740310e9 100644 --- a/tests/templates/documentFunction.tpl +++ b/tests/templates/documentFunction.tpl @@ -2,6 +2,13 @@ /** * Test Generated example of using {$fnPrefix} {$action} API. * +{if !empty($result.deprecated) && is_string($result.deprecated)} + * @deprecated + * {$result.deprecated} +{if !$description} + * +{/if} +{/if} {if $description} * {$description} * -- 2.25.1