From a828d7b823956a46f5a3cea184389c9b108f80ac Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 23 Feb 2015 11:36:57 -0500 Subject: [PATCH] CRM-15988 - Update generated examples --- api/api.php | 2 +- .../Activity/ContactRefCustomField.php | 11 +- .../Activity/ContactRefCustomFieldGet.php | 11 +- api/v3/examples/Activity/Create.php | 11 +- api/v3/examples/Activity/DateTimeHigh.php | 11 +- api/v3/examples/Activity/DateTimeLow.php | 11 +- api/v3/examples/Activity/Delete.php | 11 +- api/v3/examples/Activity/Get.php | 11 +- .../Activity/{Getfields.php => GetFields.php} | 11 +- .../Activity/GetTargetandAssignee.php | 15 +-- .../Activity/ReturnAssigneeContact.php | 13 +- api/v3/examples/ActivityContact/Create.php | 11 +- api/v3/examples/ActivityContact/Delete.php | 11 +- api/v3/examples/ActivityType/Create.php | 15 +-- api/v3/examples/ActivityType/Get.php | 15 +-- api/v3/examples/Address/AddressLike.php | 11 +- api/v3/examples/Address/AddressParse.php | 11 +- api/v3/examples/Address/AddressSort.php | 11 +- api/v3/examples/Address/Create.php | 11 +- api/v3/examples/Address/Delete.php | 11 +- api/v3/examples/Address/Get.php | 11 +- api/v3/examples/Address/GetOptions.php | 75 +++++++++++ api/v3/examples/Batch/Create.php | 43 +++--- api/v3/examples/Batch/Delete.php | 11 +- api/v3/examples/Batch/Get.php | 11 +- api/v3/examples/Campaign/Create.php | 11 +- api/v3/examples/Campaign/Delete.php | 11 +- api/v3/examples/Campaign/Get.php | 11 +- api/v3/examples/Case/Create.php | 11 +- api/v3/examples/Constant/Get.php | 15 +-- api/v3/examples/Contact/APIChainedArray.php | 11 +- .../Contact/APIChainedArrayFormats.php | 11 +- .../Contact/APIChainedArrayMultipleCustom.php | 11 +- ...IChainedArrayValuesFromSiblingFunction.php | 11 +- api/v3/examples/Contact/ChainTwoWebsites.php | 11 +- .../Contact/ChainTwoWebsitesSyntax2.php | 11 +- api/v3/examples/Contact/Create.php | 11 +- .../CreateParticipantPayment.php | 15 +-- api/v3/examples/Contact/CustomFieldGet.php | 11 +- .../CustomFieldGetReturnSyntaxVariation.php | 11 +- api/v3/examples/Contact/Delete.php | 11 +- .../examples/Contact/FormatIsSuccess_Fail.php | 11 +- .../examples/Contact/FormatIsSuccess_True.php | 11 +- api/v3/examples/Contact/FormatOnlyID.php | 11 +- api/v3/examples/Contact/FormatSingleValue.php | 11 +- api/v3/examples/Contact/Get.php | 11 +- api/v3/examples/Contact/GetActions.php | 50 +++---- api/v3/examples/Contact/GetCountContact.php | 11 +- api/v3/examples/Contact/GetFieldsOptions.php | 11 +- .../{Getoptions.php => GetOptions.php} | 11 +- api/v3/examples/Contact/GetSingleContact.php | 11 +- .../Contact/GroupFilterUsingContactAPI.php | 11 +- .../{Email => Contact}/NestedReplaceEmail.php | 15 +-- .../ContributionCreateWithHonoreeContact.php | 11 +- .../ContributionCreateWithNote.php | 11 +- .../ContributionCreateWithSoftCredit.php | 11 +- ...ntributionCreateWithSoftCreditDefaults.php | 11 +- api/v3/examples/Contribution/Create.php | 13 +- .../CreateWithNestedLineItems.php | 87 +++++++------ api/v3/examples/Contribution/Delete.php | 13 +- api/v3/examples/Contribution/Get.php | 11 +- api/v3/examples/ContributionPage/Create.php | 11 +- api/v3/examples/ContributionPage/Delete.php | 11 +- api/v3/examples/ContributionPage/Get.php | 11 +- api/v3/examples/ContributionPage/Submit.php | 11 +- api/v3/examples/ContributionRecur/Create.php | 11 +- api/v3/examples/ContributionRecur/Delete.php | 11 +- api/v3/examples/ContributionRecur/Get.php | 11 +- api/v3/examples/ContributionSoft/Create.php | 11 +- api/v3/examples/ContributionSoft/Delete.php | 11 +- api/v3/examples/ContributionSoft/Get.php | 11 +- api/v3/examples/Country/Create.php | 11 +- api/v3/examples/Country/Delete.php | 11 +- api/v3/examples/Country/Get.php | 11 +- api/v3/examples/CustomField/Create.php | 11 +- api/v3/examples/CustomField/Delete.php | 11 +- api/v3/examples/CustomGroup/Create.php | 11 +- api/v3/examples/CustomGroup/Delete.php | 11 +- api/v3/examples/CustomGroup/Get.php | 11 +- api/v3/examples/CustomValue/Create.php | 11 +- ...ormatFieldName.php => FormatFieldName.php} | 11 +- api/v3/examples/CustomValue/Get.php | 11 +- api/v3/examples/Domain/Create.php | 11 +- api/v3/examples/Domain/Get.php | 11 +- api/v3/examples/Email/Create.php | 11 +- api/v3/examples/Email/Delete.php | 11 +- api/v3/examples/Email/Replace.php | 11 +- api/v3/examples/EntityTag/Create.php | 15 +-- api/v3/examples/EntityTag/Delete.php | 11 +- api/v3/examples/EntityTag/Get.php | 25 ++-- api/v3/examples/Event/Create.php | 11 +- api/v3/examples/Event/Delete.php | 11 +- api/v3/examples/Event/Get.php | 11 +- api/v3/examples/Event/IsCurrentOption.php | 11 +- api/v3/examples/Event/IsFullOption.php | 13 +- api/v3/examples/Grant/Create.php | 11 +- api/v3/examples/Grant/Delete.php | 11 +- api/v3/examples/Grant/Get.php | 11 +- api/v3/examples/Group/Get.php | 11 +- .../Group/{getfields.php => GetFields.php} | 11 +- api/v3/examples/GroupContact/Create.php | 11 +- api/v3/examples/GroupContact/Delete.php | 11 +- api/v3/examples/GroupContact/Get.php | 11 +- .../examples/GroupContact/GetWithGroupID.php | 11 +- api/v3/examples/GroupNesting/Create.php | 11 +- api/v3/examples/GroupNesting/Delete.php | 11 +- api/v3/examples/GroupNesting/Get.php | 11 +- api/v3/examples/GroupOrganization/Create.php | 11 +- api/v3/examples/GroupOrganization/Delete.php | 11 +- api/v3/examples/GroupOrganization/Get.php | 11 +- api/v3/examples/Im/Create.php | 11 +- api/v3/examples/Im/Delete.php | 11 +- api/v3/examples/Im/Get.php | 11 +- api/v3/examples/Job/Create.php | 11 +- api/v3/examples/Job/Delete.php | 11 +- api/v3/examples/LineItem/Create.php | 11 +- api/v3/examples/LineItem/Delete.php | 11 +- api/v3/examples/LineItem/Get.php | 11 +- .../LocBlock/{simpleCreate.php => Create.php} | 11 +- ...{createEntities.php => CreateEntities.php} | 11 +- .../LocBlock/{getEntities.php => Get.php} | 11 +- .../MailSettings/ChainedGetDelete.php | 11 +- api/v3/examples/MailSettings/Create.php | 17 ++- api/v3/examples/MailSettings/Delete.php | 11 +- api/v3/examples/MailSettings/Get.php | 11 +- api/v3/examples/MailSettings/GetOptions.php | 74 +++++++++++ api/v3/examples/Mailing/Create.php | 86 ++++++++++-- api/v3/examples/Mailing/Delete.php | 13 +- api/v3/examples/Mailing/Submit.php | 34 ++--- api/v3/examples/MailingAB/Create.php | 21 ++- api/v3/examples/Membership/Create.php | 32 +++-- .../Membership/CreateWithCustomData.php | 96 ++++++++++++++ api/v3/examples/Membership/Delete.php | 11 +- ...ilterIsCurrent.php => FilterIsCurrent.php} | 11 +- api/v3/examples/Membership/Get.php | 11 +- .../{Update.php => UpdateCustomData.php} | 15 +-- api/v3/examples/MembershipPayment/Create.php | 11 +- api/v3/examples/MembershipPayment/Get.php | 11 +- api/v3/examples/MembershipStatus/Create.php | 11 +- api/v3/examples/MembershipStatus/Get.php | 11 +- api/v3/examples/MembershipType/Create.php | 11 +- api/v3/examples/MembershipType/Delete.php | 11 +- api/v3/examples/MembershipType/Get.php | 11 +- api/v3/examples/MessageTemplate/Create.php | 11 +- api/v3/examples/MessageTemplate/Delete.php | 11 +- api/v3/examples/MessageTemplate/Get.php | 11 +- api/v3/examples/Note/Create.php | 11 +- api/v3/examples/Note/Delete.php | 11 +- api/v3/examples/Note/Get.php | 11 +- api/v3/examples/OptionGroup/Create.php | 11 +- api/v3/examples/OptionGroup/Delete.php | 11 +- api/v3/examples/OptionGroup/Get.php | 11 +- api/v3/examples/OptionValue/Get.php | 11 +- api/v3/examples/OptionValue/SortOption.php | 11 +- api/v3/examples/Participant/Create.php | 11 +- api/v3/examples/Participant/Get.php | 11 +- api/v3/examples/Participant/NestedDelete.php | 11 +- .../examples/Participant/NestedEventGet.php | 11 +- api/v3/examples/ParticipantPayment/Create.php | 11 +- api/v3/examples/ParticipantPayment/Delete.php | 11 +- api/v3/examples/ParticipantPayment/Get.php | 11 +- .../examples/ParticipantStatusType/Create.php | 17 ++- .../examples/ParticipantStatusType/Delete.php | 11 +- api/v3/examples/ParticipantStatusType/Get.php | 11 +- api/v3/examples/PaymentProcessor/Create.php | 11 +- api/v3/examples/PaymentProcessor/Delete.php | 11 +- .../examples/PaymentProcessorType/Create.php | 11 +- .../examples/PaymentProcessorType/Delete.php | 11 +- api/v3/examples/Phone/Create.php | 11 +- api/v3/examples/Phone/Delete.php | 11 +- api/v3/examples/Phone/Get.php | 11 +- api/v3/examples/Phone/GetOptions.php | 75 +++++++++++ api/v3/examples/Pledge/Create.php | 17 ++- api/v3/examples/Pledge/Delete.php | 11 +- api/v3/examples/Pledge/Get.php | 15 +-- api/v3/examples/Pledge/GetFilterHighDate.php | 15 +-- api/v3/examples/PledgePayment/Create.php | 11 +- api/v3/examples/PledgePayment/Delete.php | 11 +- api/v3/examples/PledgePayment/Get.php | 11 +- api/v3/examples/PledgePayment/Update.php | 11 +- api/v3/examples/PriceField/Create.php | 11 +- api/v3/examples/PriceField/Delete.php | 11 +- api/v3/examples/PriceField/Get.php | 11 +- api/v3/examples/PriceFieldValue/Create.php | 11 +- api/v3/examples/PriceFieldValue/Delete.php | 11 +- api/v3/examples/PriceFieldValue/Get.php | 11 +- api/v3/examples/PriceSet/Create.php | 43 +++--- api/v3/examples/PriceSet/Delete.php | 11 +- api/v3/examples/PriceSet/Get.php | 11 +- api/v3/examples/Profile/Apply.php | 11 +- api/v3/examples/Profile/Get.php | 11 +- api/v3/examples/Profile/GetFields.php | 11 +- api/v3/examples/Profile/Submit.php | 11 +- .../Relationship/BetweenRelationshipType.php | 11 +- api/v3/examples/Relationship/Create.php | 11 +- api/v3/examples/Relationship/Delete.php | 11 +- api/v3/examples/Relationship/Get.php | 11 +- .../Relationship/INRelationshipType.php | 11 +- .../NotBetweenRelationshipType.php | 11 +- .../Relationship/NotInRelationshipType.php | 11 +- .../examples/Relationship/filterIsCurrent.php | 11 +- api/v3/examples/RelationshipType/Create.php | 11 +- api/v3/examples/RelationshipType/Delete.php | 11 +- api/v3/examples/ReportTemplate/Getrows.php | 11 +- .../examples/ReportTemplate/Getstatistics.php | 11 +- api/v3/examples/Setting/Create.php | 11 +- api/v3/examples/Setting/CreateAllDomains.php | 11 +- .../Setting/CreateSettingCurrentDomain.php | 11 +- .../Setting/CreateSpecifiedDomains.php | 11 +- api/v3/examples/Setting/Get.php | 11 +- api/v3/examples/Setting/GetAllDomains.php | 11 +- api/v3/examples/Setting/GetDefaults.php | 11 +- api/v3/examples/Setting/GetFields.php | 11 +- .../Setting/GetSettingCurrentDomain.php | 11 +- .../examples/Setting/GetSpecifiedDomains.php | 11 +- api/v3/examples/Setting/GetValue.php | 11 +- api/v3/examples/Setting/Revert.php | 11 +- api/v3/examples/Survey/ChainedGetDelete.php | 11 +- api/v3/examples/Survey/Create.php | 11 +- api/v3/examples/Survey/Delete.php | 11 +- api/v3/examples/Survey/Get.php | 11 +- api/v3/examples/SurveyRespondant/Get.php | 15 +-- api/v3/examples/System/Flush.php | 11 +- api/v3/examples/Tag/Create.php | 11 +- api/v3/examples/Tag/Delete.php | 11 +- api/v3/examples/Tag/Get.php | 11 +- .../Tag/{Getfields.php => GetFields.php} | 11 +- api/v3/examples/Tag/GetList.php | 11 +- ...{getReturnArray.php => GetReturnArray.php} | 11 +- api/v3/examples/UFField/Create.php | 11 +- api/v3/examples/UFField/Delete.php | 11 +- api/v3/examples/UFField/Get.php | 11 +- api/v3/examples/UFField/Replace.php | 11 +- api/v3/examples/UFGroup/Create.php | 11 +- api/v3/examples/UFGroup/Delete.php | 11 +- api/v3/examples/UFGroup/Get.php | 11 +- api/v3/examples/UFJoin/Create.php | 11 +- api/v3/examples/UFJoin/Get.php | 11 +- api/v3/examples/UFMatch/Get.php | 11 +- api/v3/examples/Website/Create.php | 11 +- api/v3/examples/Website/Delete.php | 11 +- api/v3/examples/Website/Get.php | 11 +- api/v3/examples/Website/GetFields.php | 11 +- api/v3/examples/Website/GetWithMetadata.php | 11 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 123 +++++------------- tests/phpunit/api/v3/ActivityTest.php | 11 +- tests/phpunit/api/v3/ConstantTest.php | 6 +- tests/phpunit/api/v3/ContactTest.php | 2 +- tests/phpunit/api/v3/ContributionPageTest.php | 12 +- tests/phpunit/api/v3/CustomFieldTest.php | 4 +- tests/phpunit/api/v3/CustomValueTest.php | 2 +- tests/phpunit/api/v3/EntityTagTest.php | 4 +- tests/phpunit/api/v3/EventTest.php | 2 +- tests/phpunit/api/v3/GroupTest.php | 2 +- tests/phpunit/api/v3/LocBlockTest.php | 6 +- tests/phpunit/api/v3/MembershipTest.php | 7 +- tests/phpunit/api/v3/ParticipantTest.php | 2 +- tests/phpunit/api/v3/SettingTest.php | 8 +- tests/phpunit/api/v3/SystemTest.php | 2 +- tests/phpunit/api/v3/TagTest.php | 4 +- tests/templates/documentFunction.tpl | 13 +- 261 files changed, 1824 insertions(+), 1731 deletions(-) rename api/v3/examples/Activity/{Getfields.php => GetFields.php} (98%) create mode 100644 api/v3/examples/Address/GetOptions.php rename api/v3/examples/{Participant => Contact}/CreateParticipantPayment.php (93%) rename api/v3/examples/Contact/{Getoptions.php => GetOptions.php} (86%) rename api/v3/examples/{Email => Contact}/NestedReplaceEmail.php (96%) rename api/v3/examples/CustomValue/{formatFieldName.php => FormatFieldName.php} (92%) rename api/v3/examples/Group/{getfields.php => GetFields.php} (96%) rename api/v3/examples/LocBlock/{simpleCreate.php => Create.php} (89%) rename api/v3/examples/LocBlock/{createEntities.php => CreateEntities.php} (94%) rename api/v3/examples/LocBlock/{getEntities.php => Get.php} (92%) create mode 100644 api/v3/examples/MailSettings/GetOptions.php create mode 100644 api/v3/examples/Membership/CreateWithCustomData.php rename api/v3/examples/Membership/{filterIsCurrent.php => FilterIsCurrent.php} (90%) rename api/v3/examples/Membership/{Update.php => UpdateCustomData.php} (87%) create mode 100644 api/v3/examples/Phone/GetOptions.php rename api/v3/examples/Tag/{Getfields.php => GetFields.php} (94%) rename api/v3/examples/Tag/{getReturnArray.php => GetReturnArray.php} (89%) diff --git a/api/api.php b/api/api.php index 45a46e0b56..4f53c542fc 100644 --- a/api/api.php +++ b/api/api.php @@ -105,7 +105,7 @@ function civicrm_error($result) { } /** - * Get camel case version of entity or action name. + * Get camel case version of entity name. * * @param string|null $entity * diff --git a/api/v3/examples/Activity/ContactRefCustomField.php b/api/v3/examples/Activity/ContactRefCustomField.php index 667f35181f..6d9fba5541 100644 --- a/api/v3/examples/Activity/ContactRefCustomField.php +++ b/api/v3/examples/Activity/ContactRefCustomField.php @@ -1,6 +1,6 @@ 1, 'subject' => 'Make-it-Happen Meeting', @@ -23,7 +23,7 @@ function activity__example() { ); try{ - $result = civicrm_api3('activity', '', $params); + $result = civicrm_api3('Activity', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -46,7 +46,7 @@ function activity__example() { * @return array * API result array */ -function activity__expectedresult() { +function activity_create_expectedresult() { $expectedResult = array( 'is_error' => 0, @@ -86,11 +86,10 @@ function activity__expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testActivityReturnTargetAssignee -* and can be found in +* The test that created it is called "testActivityReturnTargetAssignee" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Activity/ReturnAssigneeContact.php b/api/v3/examples/Activity/ReturnAssigneeContact.php index 07ebf0479c..545793076c 100644 --- a/api/v3/examples/Activity/ReturnAssigneeContact.php +++ b/api/v3/examples/Activity/ReturnAssigneeContact.php @@ -1,8 +1,8 @@ '', ), ), - 'deprecated' => 'The activity_type api is deprecated. Please use the option_value api instead.', + 'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.', ); return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testActivityTypeCreate -* and can be found in +* The test that created it is called "testActivityTypeCreate" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/ActivityType/Get.php b/api/v3/examples/ActivityType/Get.php index f914ae5b94..b6e93f75a9 100644 --- a/api/v3/examples/ActivityType/Get.php +++ b/api/v3/examples/ActivityType/Get.php @@ -1,9 +1,9 @@ 'Downloaded Invoice', '50' => 'Emailed Invoice', ), - 'deprecated' => 'The activity_type api is deprecated. Please use the option_value api instead.', + 'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.', ); return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testActivityTypeGet -* and can be found in +* The test that created it is called "testActivityTypeGet" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Address/AddressLike.php b/api/v3/examples/Address/AddressLike.php index eb1a856458..87d490a69b 100644 --- a/api/v3/examples/Address/AddressLike.php +++ b/api/v3/examples/Address/AddressLike.php @@ -1,6 +1,6 @@ 'location_type_id', + ); + + try{ + $result = civicrm_api3('Address', 'getoptions', $params); + } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'error' => $errorMessage, + 'error_code' => $errorCode, + 'error_data' => $errorData, + ); + } + + return $result; +} + +/** + * Function returns array of result expected from previous function. + * + * @return array + * API result array + */ +function address_getoptions_expectedresult() { + + $expectedResult = array( + 'is_error' => 0, + 'version' => 3, + 'count' => 5, + 'values' => array( + '5' => 'Billing', + '1' => 'Home', + '3' => 'Main', + '4' => 'Other', + '2' => 'Work', + ), + ); + + return $expectedResult; +} + +/* +* This example has been generated from the API test suite. +* The test that created it is called "testLocationTypeGet" +* and can be found at: +* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php +* +* You can see the outcome of the API tests at +* https://test.civicrm.org/job/CiviCRM-master-git/ +* +* To Learn about the API read +* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API +* +* Browse the api on your own site with the api explorer +* http://MYSITE.ORG/path/to/civicrm/api +* +* 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 +*/ diff --git a/api/v3/examples/Batch/Create.php b/api/v3/examples/Batch/Create.php index 213231bd9d..c5d8f447af 100644 --- a/api/v3/examples/Batch/Create.php +++ b/api/v3/examples/Batch/Create.php @@ -1,22 +1,22 @@ 'New_Batch_03', - 'title' => 'New Batch 03', - 'description' => 'This is description for New Batch 03', - 'total' => '300.33', - 'item_count' => 3, - 'status_id' => 1, + 'name' => 'New_Batch_04', + 'title' => 'New Batch 04', + 'description' => 'This is description for New Batch 04', + 'total' => '400.44', + 'item_count' => 4, + 'id' => 3, ); try{ - $result = civicrm_api3('batch', 'create', $params); + $result = civicrm_api3('Batch', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -45,23 +45,23 @@ function batch_create_expectedresult() { 'is_error' => 0, 'version' => 3, 'count' => 1, - 'id' => 2, + 'id' => 3, 'values' => array( - '2' => array( - 'id' => '2', - 'name' => 'New_Batch_03', - 'title' => 'New Batch 03', - 'description' => 'This is description for New Batch 03', + '3' => array( + 'id' => '3', + 'name' => 'New_Batch_04', + 'title' => 'New Batch 04', + 'description' => 'This is description for New Batch 04', 'created_id' => '', 'created_date' => '', 'modified_id' => '', - 'modified_date' => '2012-11-14 16:02:35', + 'modified_date' => '', 'saved_search_id' => '', - 'status_id' => '1', + 'status_id' => '', 'type_id' => '', 'mode_id' => '', - 'total' => '300.33', - 'item_count' => '3', + 'total' => '400.44', + 'item_count' => '4', 'payment_instrument_id' => '', 'exported_date' => '', 'data' => '', @@ -72,11 +72,10 @@ function batch_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreate -* and can be found in +* The test that created it is called "testUpdate" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/BatchTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Batch/Delete.php b/api/v3/examples/Batch/Delete.php index c2cb472713..b97d5573b6 100644 --- a/api/v3/examples/Batch/Delete.php +++ b/api/v3/examples/Batch/Delete.php @@ -1,6 +1,6 @@ 'Downloaded Invoice', '50' => 'Emailed Invoice', ), - 'deprecated' => 'The constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.', + 'deprecated' => 'The Constant api is deprecated as of CiviCRM 4.4. Please use the getoptions api action instead.', ); return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testActivityType -* and can be found in +* The test that created it is called "testActivityType" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Contact/APIChainedArray.php b/api/v3/examples/Contact/APIChainedArray.php index 5c78e3cb6a..fe8e67a331 100644 --- a/api/v3/examples/Contact/APIChainedArray.php +++ b/api/v3/examples/Contact/APIChainedArray.php @@ -1,6 +1,6 @@ 'Individual', 'display_name' => 'dlobo', @@ -30,7 +30,7 @@ function participant_create_example() { ); try{ - $result = civicrm_api3('participant', 'create', $params); + $result = civicrm_api3('Contact', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -53,7 +53,7 @@ function participant_create_example() { * @return array * API result array */ -function participant_create_expectedresult() { +function contact_create_expectedresult() { $expectedResult = array( 'is_error' => 0, @@ -133,11 +133,10 @@ function participant_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreateParticipantWithPayment -* and can be found in +* The test that created it is called "testCreateParticipantWithPayment" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Contact/CustomFieldGet.php b/api/v3/examples/Contact/CustomFieldGet.php index 7985aa8438..6dc057cffd 100644 --- a/api/v3/examples/Contact/CustomFieldGet.php +++ b/api/v3/examples/Contact/CustomFieldGet.php @@ -1,6 +1,6 @@ 0, 'version' => 3, - 'count' => 18, + 'count' => 23, 'values' => array( '0' => 'create', '1' => 'delete', - '2' => 'get', - '3' => 'getactions', - '4' => 'getcount', - '5' => 'getfields', - '6' => 'getlist', - '7' => 'getoptions', - '8' => 'getquick', - '9' => 'getrefcount', - '10' => 'getsingle', - '11' => 'getstat', - '12' => 'getvalue', - '13' => 'merge', - '14' => 'proximity', - '15' => 'replace', - '16' => 'setvalue', - '17' => 'update', + '2' => 'example_action1', + '3' => 'example_action2', + '4' => 'get', + '5' => 'getactions', + '6' => 'getcount', + '7' => 'getfields', + '8' => 'getlist', + '9' => 'getoptions', + '10' => 'getquick', + '11' => 'getrefcount', + '12' => 'getsingle', + '13' => 'getstat', + '14' => 'getvalue', + '15' => 'merge', + '16' => 'proximity', + '17' => 'replace', + '18' => 'setvalue', + '19' => 'type_create', + '20' => 'type_delete', + '21' => 'type_get', + '22' => 'update', ), 'deprecated' => array( 'getquick' => 'The "getquick" action is deprecated in favor of "getlist".', @@ -69,11 +74,10 @@ function contact_getactions_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testGetActions -* and can be found in +* The test that created it is called "testGetActions" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Contact/GetCountContact.php b/api/v3/examples/Contact/GetCountContact.php index 17be29dd0c..724616b3e5 100644 --- a/api/v3/examples/Contact/GetCountContact.php +++ b/api/v3/examples/Contact/GetCountContact.php @@ -1,6 +1,6 @@ 10, 'api.email.replace' => array( @@ -42,7 +42,7 @@ function email_replace_example() { ); try{ - $result = civicrm_api3('email', 'replace', $params); + $result = civicrm_api3('Contact', 'get', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -65,7 +65,7 @@ function email_replace_example() { * @return array * API result array */ -function email_replace_expectedresult() { +function contact_get_expectedresult() { $expectedResult = array( 'is_error' => 0, @@ -224,11 +224,10 @@ function email_replace_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testReplaceEmailsInChain -* and can be found in +* The test that created it is called "testReplaceEmailsInChain" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EmailTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.php b/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.php index c4c2f0ccde..fe6ec8ee09 100644 --- a/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.php +++ b/api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.php @@ -1,6 +1,6 @@ 9, + 'contact_id' => 1, 'receive_date' => '20120511', - 'total_amount' => '100', - 'financial_type_id' => 1, - 'payment_instrument_id' => 1, - 'non_deductible_amount' => '10', - 'fee_amount' => '50', - 'net_amount' => '90', + 'total_amount' => '400', + 'financial_type_id' => 7, 'trxn_id' => 12345, 'invoice_id' => 67890, 'source' => 'SSF', @@ -24,22 +20,28 @@ function contribution_create_example() { 'skipLineItem' => 1, 'api.line_item.create' => array( '0' => array( - 'price_field_id' => 1, - 'qty' => 2, - 'line_total' => '20', - 'unit_price' => '10', + 'price_field_id' => array( + '0' => 3, + ), + 'qty' => 1, + 'line_total' => '100', + 'unit_price' => '100', + 'financial_type_id' => 7, ), '1' => array( - 'price_field_id' => 1, + 'price_field_id' => array( + '0' => 3, + ), 'qty' => 1, - 'line_total' => '80', - 'unit_price' => '80', + 'line_total' => '300', + 'unit_price' => '300', + 'financial_type_id' => 8, ), ), ); try{ - $result = civicrm_api3('contribution', 'create', $params); + $result = civicrm_api3('Contribution', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -72,15 +74,15 @@ function contribution_create_expectedresult() { 'values' => array( '1' => array( 'id' => '1', - 'contact_id' => '9', - 'financial_type_id' => '1', + 'contact_id' => '1', + 'financial_type_id' => '7', 'contribution_page_id' => '', - 'payment_instrument_id' => '1', + 'payment_instrument_id' => '4', 'receive_date' => '20120511000000', - 'non_deductible_amount' => '10', - 'total_amount' => '100', - 'fee_amount' => '50', - 'net_amount' => '90', + 'non_deductible_amount' => '', + 'total_amount' => '435', + 'fee_amount' => 0, + 'net_amount' => '435', 'trxn_id' => '12345', 'invoice_id' => '67890', 'currency' => 'USD', @@ -98,8 +100,8 @@ function contribution_create_expectedresult() { 'check_number' => '', 'campaign_id' => '', 'creditnote_id' => '', - 'tax_amount' => 0, - 'contribution_type_id' => '1', + 'tax_amount' => '35', + 'contribution_type_id' => '7', 'api.line_item.create' => array( '0' => array( 'is_error' => 0, @@ -112,16 +114,18 @@ function contribution_create_expectedresult() { 'entity_table' => 'civicrm_contribution', 'entity_id' => '1', 'contribution_id' => '1', - 'price_field_id' => '1', + 'price_field_id' => array( + '0' => '3', + ), 'label' => 'line item', - 'qty' => '2', - 'unit_price' => '10', - 'line_total' => '20', + 'qty' => '1', + 'unit_price' => '100', + 'line_total' => '100', 'participant_count' => '', 'price_field_value_id' => '', - 'financial_type_id' => '', + 'financial_type_id' => '7', 'deductible_amount' => '', - 'tax_amount' => '', + 'tax_amount' => '20', ), ), ), @@ -136,16 +140,18 @@ function contribution_create_expectedresult() { 'entity_table' => 'civicrm_contribution', 'entity_id' => '1', 'contribution_id' => '1', - 'price_field_id' => '1', + 'price_field_id' => array( + '0' => '3', + ), 'label' => 'line item', 'qty' => '1', - 'unit_price' => '80', - 'line_total' => '80', + 'unit_price' => '300', + 'line_total' => '300', 'participant_count' => '', 'price_field_value_id' => '', - 'financial_type_id' => '', + 'financial_type_id' => '8', 'deductible_amount' => '', - 'tax_amount' => '', + 'tax_amount' => '15', ), ), ), @@ -157,12 +163,11 @@ function contribution_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreateContributionChainedLineItems -* and can be found in -* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php +* The test that created it is called "testCreateContributionChainedLineItems" +* and can be found at: +* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php * * You can see the outcome of the API tests at * https://test.civicrm.org/job/CiviCRM-master-git/ diff --git a/api/v3/examples/Contribution/Delete.php b/api/v3/examples/Contribution/Delete.php index 9617d619b2..0242584211 100644 --- a/api/v3/examples/Contribution/Delete.php +++ b/api/v3/examples/Contribution/Delete.php @@ -1,6 +1,6 @@ 12, - 'tag_id' => '9', + 'contact_id' => 3, + 'tag_id' => '6', ); try{ - $result = civicrm_api3('entity_tag', 'create', $params); + $result = civicrm_api3('EntityTag', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -47,11 +47,10 @@ function entity_tag_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testContactEntityTagCreate -* and can be found in +* The test that created it is called "testIndividualEntityTagGet" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityTagTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/EntityTag/Delete.php b/api/v3/examples/EntityTag/Delete.php index d07a39b33b..faecc36c6d 100644 --- a/api/v3/examples/EntityTag/Delete.php +++ b/api/v3/examples/EntityTag/Delete.php @@ -1,6 +1,6 @@ 21, - 'tag_id' => '12', + 'contact_id' => 3, ); try{ - $result = civicrm_api3('entity_tag', 'get', $params); + $result = civicrm_api3('EntityTag', 'get', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -39,19 +38,23 @@ function entity_tag_get_expectedresult() { $expectedResult = array( 'is_error' => 0, - 'not_added' => 0, - 'added' => 1, - 'total_count' => 1, + 'version' => 3, + 'count' => 1, + 'id' => 6, + 'values' => array( + '6' => array( + 'tag_id' => '6', + ), + ), ); return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testIndividualEntityTagGet -* and can be found in +* The test that created it is called "testIndividualEntityTagGet" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EntityTagTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Event/Create.php b/api/v3/examples/Event/Create.php index c458ff6e27..2b0363e88d 100644 --- a/api/v3/examples/Event/Create.php +++ b/api/v3/examples/Event/Create.php @@ -1,6 +1,6 @@ 0, 'allow_same_participant_emails' => 0, 'is_template' => 0, - 'created_date' => '2015-02-16 11:40:40', + 'created_date' => '2015-02-22 23:13:11', 'is_share' => '1', 'is_confirm_enabled' => '1', 'is_billing_required' => 0, @@ -72,11 +72,10 @@ function event_getsingle_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testGetSingleReturnIsFull -* and can be found in +* The test that created it is called "testGetSingleReturnIsFull" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Grant/Create.php b/api/v3/examples/Grant/Create.php index 2b69bde540..519c097937 100644 --- a/api/v3/examples/Grant/Create.php +++ b/api/v3/examples/Grant/Create.php @@ -1,6 +1,6 @@ 0, 'version' => 3, 'count' => 1, - 'id' => 2, + 'id' => 5, 'values' => array( - '2' => array( - 'id' => '2', + '5' => array( + 'id' => '5', 'domain_id' => '1', 'name' => 'my mail setting', 'is_default' => '1', @@ -71,11 +71,10 @@ function mail_settings_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreateMailSettings -* and can be found in +* The test that created it is called "testDeleteMailSettings" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailSettingsTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/MailSettings/Delete.php b/api/v3/examples/MailSettings/Delete.php index 7dbfae3d3a..14cf3ba324 100644 --- a/api/v3/examples/MailSettings/Delete.php +++ b/api/v3/examples/MailSettings/Delete.php @@ -1,6 +1,6 @@ 'protocol', + ); + + try{ + $result = civicrm_api3('MailSettings', 'getoptions', $params); + } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'error' => $errorMessage, + 'error_code' => $errorCode, + 'error_data' => $errorData, + ); + } + + return $result; +} + +/** + * Function returns array of result expected from previous function. + * + * @return array + * API result array + */ +function mail_settings_getoptions_expectedresult() { + + $expectedResult = array( + 'is_error' => 0, + 'version' => 3, + 'count' => 4, + 'values' => array( + '1' => 'IMAP', + '2' => 'Maildir', + '3' => 'POP3', + '4' => 'Localdir', + ), + ); + + return $expectedResult; +} + +/* +* This example has been generated from the API test suite. +* The test that created it is called "testmailProtocol" +* and can be found at: +* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php +* +* You can see the outcome of the API tests at +* https://test.civicrm.org/job/CiviCRM-master-git/ +* +* To Learn about the API read +* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API +* +* Browse the api on your own site with the api explorer +* http://MYSITE.ORG/path/to/civicrm/api +* +* 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 +*/ diff --git a/api/v3/examples/Mailing/Create.php b/api/v3/examples/Mailing/Create.php index 98feb8fd41..5772aa6201 100644 --- a/api/v3/examples/Mailing/Create.php +++ b/api/v3/examples/Mailing/Create.php @@ -1,6 +1,6 @@ '

This is {contact.display_name}.

{domain.address}{action.optOutUrl}

', 'name' => 'mailing name', - 'created_id' => 3, + 'created_id' => 9, 'header_id' => '', 'footer_id' => '', - 'scheduled_date' => 'now', + 'groups' => array( + 'include' => array( + '0' => 7, + ), + 'exclude' => array( + '0' => 8, + ), + ), + 'mailings' => array( + 'include' => array(), + 'exclude' => array(), + ), + 'options' => array( + 'force_rollback' => 1, + ), + 'api.mailing_job.create' => 1, + 'api.MailingRecipients.get' => array( + 'mailing_id' => '$value.id', + 'api.contact.getvalue' => array( + 'return' => 'display_name', + ), + 'api.email.getvalue' => array( + 'return' => 'email', + ), + ), ); try{ - $result = civicrm_api3('mailing', 'create', $params); + $result = civicrm_api3('Mailing', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -48,10 +72,10 @@ function mailing_create_expectedresult() { 'is_error' => 0, 'version' => 3, 'count' => 1, - 'id' => 1, + 'id' => 4, 'values' => array( - '1' => array( - 'id' => '1', + '4' => array( + 'id' => '4', 'domain_id' => '1', 'header_id' => '', 'footer_id' => '', @@ -74,10 +98,10 @@ function mailing_create_expectedresult() { 'is_completed' => '', 'msg_template_id' => '', 'override_verp' => '1', - 'created_id' => '3', + 'created_id' => '9', 'created_date' => '2013-07-28 08:49:19', 'scheduled_id' => '', - 'scheduled_date' => '20130728085413', + 'scheduled_date' => '', 'approver_id' => '', 'approval_date' => '', 'approval_status_id' => '', @@ -90,6 +114,43 @@ function mailing_create_expectedresult() { 'hash' => '', 'location_type_id' => '', 'email_selection_method' => '', + 'api.mailing_job.create' => array( + 'is_error' => 0, + 'version' => 3, + 'count' => 1, + 'id' => 5, + 'values' => array( + '0' => array( + 'id' => '5', + 'mailing_id' => '4', + 'scheduled_date' => '20130728085413', + 'start_date' => '', + 'end_date' => '', + 'status' => 'Scheduled', + 'is_test' => 0, + 'job_type' => '', + 'parent_id' => '', + 'job_offset' => '', + 'job_limit' => '', + ), + ), + ), + 'api.MailingRecipients.get' => array( + 'is_error' => 0, + 'version' => 3, + 'count' => 1, + 'id' => 4, + 'values' => array( + '0' => array( + 'id' => '4', + 'mailing_id' => '4', + 'contact_id' => '10', + 'email_id' => '10', + 'api.contact.getvalue' => 'Mr. Includer Person II', + 'api.email.getvalue' => 'include.me@example.org', + ), + ), + ), ), ), ); @@ -97,11 +158,10 @@ function mailing_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testMailerCreateSuccess -* and can be found in +* The test that created it is called "testMailerPreviewRecipients" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Mailing/Delete.php b/api/v3/examples/Mailing/Delete.php index f7caaba88d..4f60cc881c 100644 --- a/api/v3/examples/Mailing/Delete.php +++ b/api/v3/examples/Mailing/Delete.php @@ -1,17 +1,17 @@ 16, + 'id' => 18, ); try{ - $result = civicrm_api3('mailing', 'delete', $params); + $result = civicrm_api3('Mailing', 'delete', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -46,11 +46,10 @@ function mailing_delete_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testMailerDeleteSuccess -* and can be found in +* The test that created it is called "testMailerDeleteSuccess" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Mailing/Submit.php b/api/v3/examples/Mailing/Submit.php index 4f6b8b5f22..fbf518322b 100644 --- a/api/v3/examples/Mailing/Submit.php +++ b/api/v3/examples/Mailing/Submit.php @@ -1,6 +1,6 @@ '2014-12-13 10:00:00', - 'id' => 9, + 'approval_date' => '2014-12-13 00:00:00', + 'id' => 16, ); try{ - $result = civicrm_api3('mailing', 'submit', $params); + $result = civicrm_api3('Mailing', 'submit', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -41,13 +42,13 @@ function mailing_submit_expectedresult() { 'is_error' => 0, 'version' => 3, 'count' => 1, - 'id' => 9, + 'id' => 16, 'values' => array( - '9' => array( - 'id' => '9', + '16' => array( + 'id' => '16', 'domain_id' => '1', 'header_id' => '', - 'footer_id' => '', + 'footer_id' => '24', 'reply_id' => '8', 'unsubscribe_id' => '5', 'resubscribe_id' => '6', @@ -59,7 +60,7 @@ function mailing_submit_expectedresult() { 'subject' => 'Hello {contact.display_name}', 'body_text' => 'This is {contact.display_name}. {domain.address}{action.optOutUrl}', - 'body_html' => '

This is {contact.display_name}.

{domain.address}{action.optOutUrl}

', + 'body_html' => '

Look ma, magic tokens in the markup!

', 'url_tracking' => '1', 'forward_replies' => 0, 'auto_responder' => 0, @@ -67,13 +68,13 @@ function mailing_submit_expectedresult() { 'is_completed' => '', 'msg_template_id' => '', 'override_verp' => '1', - 'created_id' => '22', + 'created_id' => '35', 'created_date' => '2013-07-28 08:49:19', - 'scheduled_id' => '22', + 'scheduled_id' => '36', 'scheduled_date' => '20130728085413', - 'approver_id' => '', - 'approval_date' => '', - 'approval_status_id' => '', + 'approver_id' => '36', + 'approval_date' => '20130728085413', + 'approval_status_id' => '1', 'approval_note' => '', 'is_archived' => 0, 'visibility' => 'Public Pages', @@ -90,11 +91,10 @@ function mailing_submit_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testMailerSubmit -* and can be found in +* The test that created it is called "testMailerSubmit" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/MailingAB/Create.php b/api/v3/examples/MailingAB/Create.php index a211808822..674ea54bf9 100644 --- a/api/v3/examples/MailingAB/Create.php +++ b/api/v3/examples/MailingAB/Create.php @@ -1,6 +1,6 @@ 1, 'mailing_id_b' => 2, 'mailing_id_c' => 3, - 'testing_criteria_id' => 1, - 'winner_criteria_id' => 1, + 'testing_criteria' => 'subject', + 'winner_criteria' => 'open', 'declare_winning_time' => '+2 days', 'group_percentage' => 10, ); try{ - $result = civicrm_api3('mailing_a_b', 'create', $params); + $result = civicrm_api3('MailingAB', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -56,10 +56,10 @@ function mailing_a_b_create_expectedresult() { 'mailing_id_b' => '2', 'mailing_id_c' => '3', 'domain_id' => '1', - 'testing_criteria_id' => '1', - 'winner_criteria_id' => '1', + 'testing_criteria_id' => '', + 'winner_criteria_id' => '', 'specific_url' => '', - 'declare_winning_time' => '20150218114218', + 'declare_winning_time' => '20150224231452', 'group_percentage' => '10', ), ), @@ -68,11 +68,10 @@ function mailing_a_b_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testMailingABCreateSuccess -* and can be found in +* The test that created it is called "testMailingABCreateSuccess" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MailingABTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Membership/Create.php b/api/v3/examples/Membership/Create.php index b6ac9d7804..0821f6b1db 100644 --- a/api/v3/examples/Membership/Create.php +++ b/api/v3/examples/Membership/Create.php @@ -1,25 +1,24 @@ 88, - 'membership_type_id' => 53, - 'join_date' => '2009-01-21', - 'start_date' => '2009-01-21', - 'end_date' => '2009-12-21', + 'contact_id' => 76, + 'membership_type_id' => 45, + 'join_date' => '2006-01-21', + 'start_date' => '2006-01-21', + 'end_date' => '2006-12-21', 'source' => 'Payment', 'is_override' => 1, - 'status_id' => 33, - 'custom_1' => 'custom string', + 'status_id' => 29, ); try{ - $result = civicrm_api3('membership', 'create', $params); + $result = civicrm_api3('Membership', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -52,13 +51,13 @@ function membership_create_expectedresult() { 'values' => array( '1' => array( 'id' => '1', - 'contact_id' => '88', - 'membership_type_id' => '53', - 'join_date' => '20090121000000', + 'contact_id' => '76', + 'membership_type_id' => '45', + 'join_date' => '20060121000000', 'start_date' => '2013-07-29 00:00:00', 'end_date' => '2013-08-04 00:00:00', 'source' => 'Payment', - 'status_id' => '33', + 'status_id' => '29', 'is_override' => '1', 'owner_membership_id' => '', 'max_related' => '', @@ -73,11 +72,10 @@ function membership_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreateWithCustom -* and can be found in +* The test that created it is called "testMembershipCreate" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Membership/CreateWithCustomData.php b/api/v3/examples/Membership/CreateWithCustomData.php new file mode 100644 index 0000000000..79ecdb7325 --- /dev/null +++ b/api/v3/examples/Membership/CreateWithCustomData.php @@ -0,0 +1,96 @@ + 88, + 'membership_type_id' => 53, + 'join_date' => '2009-01-21', + 'start_date' => '2009-01-21', + 'end_date' => '2009-12-21', + 'source' => 'Payment', + 'is_override' => 1, + 'status_id' => 33, + 'custom_1' => 'custom string', + ); + + try{ + $result = civicrm_api3('Membership', 'create', $params); + } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'error' => $errorMessage, + 'error_code' => $errorCode, + 'error_data' => $errorData, + ); + } + + return $result; +} + +/** + * Function returns array of result expected from previous function. + * + * @return array + * API result array + */ +function membership_create_expectedresult() { + + $expectedResult = array( + 'is_error' => 0, + 'version' => 3, + 'count' => 1, + 'id' => 1, + 'values' => array( + '1' => array( + 'id' => '1', + 'contact_id' => '88', + 'membership_type_id' => '53', + 'join_date' => '20090121000000', + 'start_date' => '2013-07-29 00:00:00', + 'end_date' => '2013-08-04 00:00:00', + 'source' => 'Payment', + 'status_id' => '33', + 'is_override' => '1', + 'owner_membership_id' => '', + 'max_related' => '', + 'is_test' => 0, + 'is_pay_later' => '', + 'contribution_recur_id' => '', + 'campaign_id' => '', + ), + ), + ); + + return $expectedResult; +} + +/* +* This example has been generated from the API test suite. +* The test that created it is called "testCreateWithCustom" +* and can be found at: +* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTest.php +* +* You can see the outcome of the API tests at +* https://test.civicrm.org/job/CiviCRM-master-git/ +* +* To Learn about the API read +* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API +* +* Browse the api on your own site with the api explorer +* http://MYSITE.ORG/path/to/civicrm/api +* +* 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 +*/ diff --git a/api/v3/examples/Membership/Delete.php b/api/v3/examples/Membership/Delete.php index 29ef67b90b..8ed8df71ce 100644 --- a/api/v3/examples/Membership/Delete.php +++ b/api/v3/examples/Membership/Delete.php @@ -1,6 +1,6 @@ 106, 'membership_type_id' => 65, @@ -19,7 +19,7 @@ function membership_update_example() { ); try{ - $result = civicrm_api3('membership', 'update', $params); + $result = civicrm_api3('Membership', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -42,7 +42,7 @@ function membership_update_example() { * @return array * API result array */ -function membership_update_expectedresult() { +function membership_create_expectedresult() { $expectedResult = array( 'is_error' => 0, @@ -73,11 +73,10 @@ function membership_update_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testUpdateWithCustom -* and can be found in +* The test that created it is called "testUpdateWithCustom" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/MembershipTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/MembershipPayment/Create.php b/api/v3/examples/MembershipPayment/Create.php index 149fc257de..3550d327eb 100644 --- a/api/v3/examples/MembershipPayment/Create.php +++ b/api/v3/examples/MembershipPayment/Create.php @@ -1,6 +1,6 @@ 0, 'version' => 3, 'count' => 1, - 'id' => 16, + 'id' => 17, 'values' => array( - '16' => array( - 'id' => '16', + '17' => array( + 'id' => '17', 'name' => 'test status', 'label' => 'I am a test', 'class' => 'Positive', @@ -66,11 +66,10 @@ function participant_status_type_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreateParticipantStatusType -* and can be found in +* The test that created it is called "testGetParticipantStatusType" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantStatusTypeTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/ParticipantStatusType/Delete.php b/api/v3/examples/ParticipantStatusType/Delete.php index 15d5c8b9ce..7b2a442791 100644 --- a/api/v3/examples/ParticipantStatusType/Delete.php +++ b/api/v3/examples/ParticipantStatusType/Delete.php @@ -1,6 +1,6 @@ 'phone_type_id', + ); + + try{ + $result = civicrm_api3('Phone', 'getoptions', $params); + } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'error' => $errorMessage, + 'error_code' => $errorCode, + 'error_data' => $errorData, + ); + } + + return $result; +} + +/** + * Function returns array of result expected from previous function. + * + * @return array + * API result array + */ +function phone_getoptions_expectedresult() { + + $expectedResult = array( + 'is_error' => 0, + 'version' => 3, + 'count' => 5, + 'values' => array( + '1' => 'Phone', + '2' => 'Mobile', + '3' => 'Fax', + '4' => 'Pager', + '5' => 'Voicemail', + ), + ); + + return $expectedResult; +} + +/* +* This example has been generated from the API test suite. +* The test that created it is called "testPhoneType" +* and can be found at: +* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ConstantTest.php +* +* You can see the outcome of the API tests at +* https://test.civicrm.org/job/CiviCRM-master-git/ +* +* To Learn about the API read +* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API +* +* Browse the api on your own site with the api explorer +* http://MYSITE.ORG/path/to/civicrm/api +* +* 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 +*/ diff --git a/api/v3/examples/Pledge/Create.php b/api/v3/examples/Pledge/Create.php index bf5e17d311..6bd0f386de 100644 --- a/api/v3/examples/Pledge/Create.php +++ b/api/v3/examples/Pledge/Create.php @@ -1,6 +1,6 @@ 11, - 'pledge_create_date' => '20150216', - 'start_date' => '20150216', - 'scheduled_date' => '20150218', + 'pledge_create_date' => '20150222', + 'start_date' => '20150222', + 'scheduled_date' => '20150224', 'amount' => '100', 'pledge_status_id' => '2', 'pledge_financial_type_id' => '1', @@ -23,7 +23,7 @@ function pledge_create_example() { ); try{ - $result = civicrm_api3('pledge', 'create', $params); + $result = civicrm_api3('Pledge', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -85,11 +85,10 @@ function pledge_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreatePledge -* and can be found in +* The test that created it is called "testCreatePledge" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Pledge/Delete.php b/api/v3/examples/Pledge/Delete.php index 9ea54b0972..02b53fdf62 100644 --- a/api/v3/examples/Pledge/Delete.php +++ b/api/v3/examples/Pledge/Delete.php @@ -1,6 +1,6 @@ 'Mr. Anthony Anderson II', 'pledge_id' => '1', 'pledge_amount' => '100.00', - 'pledge_create_date' => '2015-02-16 00:00:00', + 'pledge_create_date' => '2015-02-22 00:00:00', 'pledge_status' => 'Pending', 'pledge_total_paid' => '', - 'pledge_next_pay_date' => '2015-02-18 00:00:00', + 'pledge_next_pay_date' => '2015-02-24 00:00:00', 'pledge_next_pay_amount' => '20.00', 'pledge_outstanding_amount' => '', 'pledge_financial_type' => 'Donation', @@ -71,11 +71,10 @@ function pledge_get_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testGetPledge -* and can be found in +* The test that created it is called "testGetPledge" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/Pledge/GetFilterHighDate.php b/api/v3/examples/Pledge/GetFilterHighDate.php index ee4847a390..6e52589e8e 100644 --- a/api/v3/examples/Pledge/GetFilterHighDate.php +++ b/api/v3/examples/Pledge/GetFilterHighDate.php @@ -1,6 +1,6 @@ '20150214114707', + 'pledge_start_date_high' => '20150220231942', ); try{ - $result = civicrm_api3('pledge', 'get', $params); + $result = civicrm_api3('Pledge', 'get', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -52,7 +52,7 @@ function pledge_get_expectedresult() { 'display_name' => 'Mr. Anthony Anderson II', 'pledge_id' => '2', 'pledge_amount' => '100.00', - 'pledge_create_date' => '2015-02-16 00:00:00', + 'pledge_create_date' => '2015-02-22 00:00:00', 'pledge_status' => 'Overdue', 'pledge_total_paid' => '', 'pledge_next_pay_date' => '2014-03-07 00:00:00', @@ -73,11 +73,10 @@ function pledge_get_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testPledgeGetReturnFilters -* and can be found in +* The test that created it is called "testPledgeGetReturnFilters" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PledgeTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/PledgePayment/Create.php b/api/v3/examples/PledgePayment/Create.php index 82212aa938..1e8c21e3eb 100644 --- a/api/v3/examples/PledgePayment/Create.php +++ b/api/v3/examples/PledgePayment/Create.php @@ -1,6 +1,6 @@ 'some_price_set', - 'title' => 'Some Price Set', - 'is_active' => 1, - 'financial_type_id' => 1, - 'extends' => array( - '0' => 1, - '1' => 2, - ), + 'entity_table' => 'civicrm_event', + 'entity_id' => 1, + 'name' => 'event price', + 'title' => 'event price', + 'extends' => 1, ); try{ - $result = civicrm_api3('price_set', 'create', $params); + $result = civicrm_api3('PriceSet', 'create', $params); } catch (CiviCRM_API3_Exception $e) { // Handle error here. @@ -47,22 +44,19 @@ function price_set_create_expectedresult() { 'is_error' => 0, 'version' => 3, 'count' => 1, - 'id' => 16, + 'id' => 18, 'values' => array( - '16' => array( - 'id' => '16', + '18' => array( + 'id' => '18', 'domain_id' => '', - 'name' => 'some_price_set', - 'title' => 'Some Price Set', - 'is_active' => '1', + 'name' => 'event price', + 'title' => 'event price', + 'is_active' => '', 'help_pre' => '', 'help_post' => '', 'javascript' => '', - 'extends' => array( - '0' => '1', - '1' => '2', - ), - 'financial_type_id' => '1', + 'extends' => '1', + 'financial_type_id' => '', 'is_quick_config' => '', 'is_reserved' => '', ), @@ -72,11 +66,10 @@ function price_set_create_expectedresult() { return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testCreatePriceSetForEventAndContribution -* and can be found in +* The test that created it is called "testEventPriceSet" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PriceSetTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/PriceSet/Delete.php b/api/v3/examples/PriceSet/Delete.php index efe0a03815..5360087383 100644 --- a/api/v3/examples/PriceSet/Delete.php +++ b/api/v3/examples/PriceSet/Delete.php @@ -1,6 +1,6 @@ 3, 'count' => 0, 'values' => array(), - 'deprecated' => 'The survey_respondant api is not currently supported.', + 'deprecated' => 'The SurveyRespondant api is not currently supported.', ); return $expectedResult; } -/** +/* * This example has been generated from the API test suite. -* The test that created it is called -* testGetSurveyRespondants -* and can be found in +* The test that created it is called "testGetSurveyRespondants" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SurveyRespondantTest.php * * You can see the outcome of the API tests at diff --git a/api/v3/examples/System/Flush.php b/api/v3/examples/System/Flush.php index e1f397ec4a..0d124c2144 100644 --- a/api/v3/examples/System/Flush.php +++ b/api/v3/examples/System/Flush.php @@ -1,6 +1,6 @@ _apiversion; $result = $this->callAPISuccess($entity, $action, $params); - $this->documentMe($params, $result, $function, $file, $description, $subfile, $actionName); + $this->documentMe($entity, $action, $params, $result, $function, $file, $description, $exampleName); return $result; } @@ -2249,100 +2249,50 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * define(DONT_DOCUMENT_TEST_CONFIG ,1); * in your settings file * + * @param string $entity + * @param string $action * @param array $params * Array as passed to civicrm_api function. * @param array $result * Array as received from the civicrm_api function. - * @param string $function + * @param string $testFunction * Calling function - generally __FUNCTION__. - * @param string $filename + * @param string $testFile * Called from file - generally __FILE__. * @param string $description * Descriptive text for the example file. - * @param string $subfile - * Name for subfile - if this is completed the example will be put in a subfolder (named by the entity). - * @param string $action - * Optional action - otherwise taken from function name. + * @param string $exampleName + * Name for this example file (CamelCase) - if ommitted the action name will be substituted. */ - public function documentMe($params, $result, $function, $filename, $description = "", $subfile = NULL, $action = NULL) { + private function documentMe($entity, $action, $params, $result, $testFunction, $testFile, $description = "", $exampleName = NULL) { if (defined('DONT_DOCUMENT_TEST_CONFIG') && DONT_DOCUMENT_TEST_CONFIG) { return; } - $entity = substr(basename($filename), 0, strlen(basename($filename)) - 8); - //todo - this is a bit cludgey - if (empty($action)) { - if (strstr($function, 'Create')) { - $action = empty($action) ? 'create' : $action; - $entityAction = 'Create'; - } - elseif (strstr($function, 'GetSingle')) { - $action = empty($action) ? 'getsingle' : $action; - $entityAction = 'GetSingle'; - } - elseif (strstr($function, 'GetValue')) { - $action = empty($action) ? 'getvalue' : $action; - $entityAction = 'GetValue'; - } - elseif (strstr($function, 'GetCount')) { - $action = empty($action) ? 'getcount' : $action; - $entityAction = 'GetCount'; - } - elseif (strstr($function, 'GetFields')) { - $action = empty($action) ? 'getfields' : $action; - $entityAction = 'GetFields'; - } - elseif (strstr($function, 'GetList')) { - $action = empty($action) ? 'getlist' : $action; - $entityAction = 'GetList'; - } - elseif (strstr($function, 'GetActions')) { - $action = empty($action) ? 'getactions' : $action; - $entityAction = 'GetActions'; - } - elseif (strstr($function, 'Get')) { - $action = empty($action) ? 'get' : $action; - $entityAction = 'Get'; - } - elseif (strstr($function, 'Delete')) { - $action = empty($action) ? 'delete' : $action; - $entityAction = 'Delete'; - } - elseif (strstr($function, 'Update')) { - $action = empty($action) ? 'update' : $action; - $entityAction = 'Update'; - } - elseif (strstr($function, 'Subscribe')) { - $action = empty($action) ? 'subscribe' : $action; - $entityAction = 'Subscribe'; - } - elseif (strstr($function, 'Submit')) { - $action = empty($action) ? 'submit' : $action; - $entityAction = 'Submit'; - } - elseif (strstr($function, 'Apply')) { - $action = empty($action) ? 'apply' : $action; - $entityAction = 'Apply'; - } - elseif (strstr($function, 'Replace')) { - $action = empty($action) ? 'replace' : $action; - $entityAction = 'Replace'; + $entity = _civicrm_api_get_camel_name($entity); + $action = strtolower($action); + + if (empty($exampleName)) { + // Attempt to convert lowercase action name to CamelCase. + // This is clunky/imperfect due to the convention of all lowercase actions. + $exampleName = CRM_Utils_String::convertStringToCamel($action); + $knownPrefixes = array( + 'Get', + 'Set', + 'Create', + 'Update', + 'Send', + ); + foreach ($knownPrefixes as $prefix) { + if (strpos($exampleName, $prefix) === 0 && $prefix != $exampleName) { + $exampleName[strlen($prefix)] = strtoupper($exampleName[strlen($prefix)]); + } } } - else { - $entityAction = ucwords($action); - } $this->tidyExampleResult($result); if (isset($params['version'])) { unset($params['version']); } - // a cleverer person than me would do it in a single regex - if (strstr($entity, 'UF')) { - $fnPrefix = strtolower(preg_replace('/(?assign('testfunction', $function); - $function = $fnPrefix . "_" . strtolower($action); - $smarty->assign('function', $function); - $smarty->assign('fnPrefix', $fnPrefix); + $smarty->assign('testFunction', $testFunction); + $smarty->assign('function', _civicrm_api_get_entity_name_from_camel($entity) . "_$action"); $smarty->assign('params', $params); $smarty->assign('entity', $entity); - $smarty->assign('filename', basename($filename)); + $smarty->assign('testFile', basename($testFile)); $smarty->assign('description', $desc); $smarty->assign('result', $result); - $smarty->assign('action', $action); - if (empty($subfile)) { - $subfile = $entityAction; - } + if (file_exists('../tests/templates/documentFunction.tpl')) { if (!is_dir("../api/v3/examples/$entity")) { mkdir("../api/v3/examples/$entity"); } - $f = fopen("../api/v3/examples/$entity/$subfile.php", "w+b"); + $f = fopen("../api/v3/examples/$entity/$exampleName.php", "w+b"); fwrite($f, $smarty->fetch('../tests/templates/documentFunction.tpl')); fclose($f); } diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index e8aafa0b63..0236aed7c8 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -411,11 +411,11 @@ class api_v3_ActivityTest extends CiviUnitTestCase { $params = $this->_params; $params['custom_' . $customField['id']] = "$this->_contactID"; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile, 'Create'); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile); $result = $this->callAPIAndDocument($this->_entity, 'get', array( 'return.custom_' . $customField['id'] => 1, 'id' => $result['id'], - ), __FUNCTION__, __FILE__, 'Get with Contact Ref Custom Field', 'ContactRefCustomFieldGet', 'get'); + ), __FUNCTION__, __FILE__, 'Get with Contact Ref Custom Field', 'ContactRefCustomFieldGet'); $this->assertEquals('Anderson, Anthony', $result['values'][$result['id']]['custom_' . $customField['id']]); $this->assertEquals($this->_contactID, $result['values'][$result['id']]['custom_' . $customField['id'] . "_id"], ' in line ' . __LINE__); @@ -501,7 +501,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase { */ public function testActivityGetGoodID1() { // Insert rows in civicrm_activity creating activities 4 and 13 - $description = "Demonstrates getting asignee_contact_id & using it to get the contact."; + $description = "Demonstrates getting assignee_contact_id & using it to get the contact."; $subfile = 'ReturnAssigneeContact'; $activity = $this->callAPISuccess('activity', 'create', $this->_params); @@ -794,8 +794,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase { 'version' => $this->_apiversion, ); - $result = $this->callAPISuccess('activity', 'delete', $params); - $this->documentMe($params, $result, __FUNCTION__, __FILE__); + $this->callAPIAndDocument('activity', 'delete', $params, __FUNCTION__, __FILE__); } /** @@ -1176,7 +1175,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase { */ public function testGetFields() { $params = array('action' => 'create'); - $result = $this->callAPIAndDocument('activity', 'getfields', $params, __FUNCTION__, __FILE__, NULL, NULL, 'getfields'); + $result = $this->callAPIAndDocument('activity', 'getfields', $params, __FUNCTION__, __FILE__, NULL, NULL); $this->assertTrue(is_array($result['values']), 'get fields doesn\'t return values array'); foreach ($result['values'] as $key => $value) { $this->assertTrue(is_array($value), $key . " is not an array"); diff --git a/tests/phpunit/api/v3/ConstantTest.php b/tests/phpunit/api/v3/ConstantTest.php index 85ed7ff58f..125ba413f1 100644 --- a/tests/phpunit/api/v3/ConstantTest.php +++ b/tests/phpunit/api/v3/ConstantTest.php @@ -101,7 +101,7 @@ class api_v3_ConstantTest extends CiviUnitTestCase { $params = array( 'field' => 'location_type_id', ); - $result = $this->callAPISuccess('address', 'getoptions', $params); + $result = $this->callAPIAndDocument('address', 'getoptions', $params, __FUNCTION__, __FILE__); $this->assertTrue($result['count'] > 3, "In line " . __LINE__); $this->assertContains('Home', $result['values'], "In line " . __LINE__); $this->assertContains('Work', $result['values'], "In line " . __LINE__); @@ -116,7 +116,7 @@ class api_v3_ConstantTest extends CiviUnitTestCase { $params = array( 'field' => 'phone_type_id', ); - $result = $this->callAPISuccess('phone', 'getoptions', $params); + $result = $this->callAPIAndDocument('phone', 'getoptions', $params, __FUNCTION__, __FILE__); $this->assertEquals(5, $result['count'], "In line " . __LINE__); $this->assertContains('Phone', $result['values'], "In line " . __LINE__); @@ -133,7 +133,7 @@ class api_v3_ConstantTest extends CiviUnitTestCase { $params = array( 'field' => 'protocol', ); - $result = $this->callAPISuccess('mail_settings', 'getoptions', $params); + $result = $this->callAPIAndDocument('mail_settings', 'getoptions', $params, __FUNCTION__, __FILE__); $this->assertEquals(4, $result['count'], "In line " . __LINE__); $this->assertContains('IMAP', $result['values'], "In line " . __LINE__); diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index a8a7f03eb9..9b60665380 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -1728,7 +1728,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { It will be ignored if there is not exactly 1 result"; $subFile = "FormatSingleValue"; $params = array('id' => 17, 'return' => 'display_name'); - $result = $this->callAPIAndDocument('Contact', 'getvalue', $params, __FUNCTION__, __FILE__, $description, $subFile, 'getvalue'); + $result = $this->callAPIAndDocument('Contact', 'getvalue', $params, __FUNCTION__, __FILE__, $description, $subFile); $this->assertEquals('Test Contact', $result); $this->callAPISuccess('Contact', 'Delete', $params); } diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 92d73a9db7..6361c6481c 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -165,7 +165,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { ); - $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); + $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page'])); $this->callAPISuccess('membership_payment', 'getsingle', array('contribution_id' => $contribution['id'])); } @@ -185,7 +185,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'selectMembership' => $this->_ids['membership_type'], ); - $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); + $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); $contributions = $this->callAPISuccess('contribution', 'get', array('contribution_page_id' => $this->_ids['contribution_page'])); $this->assertCount(2, $contributions['values']); $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array()); @@ -211,7 +211,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'selectMembership' => $this->_ids['membership_type'][1], ); - $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); + $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); $contributions = $this->callAPISuccess('contribution', 'get', array('contribution_page_id' => $this->_ids['contribution_page'])); $this->assertCount(2, $contributions['values']); $ids = array_keys($contributions['values']); @@ -243,7 +243,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'cvv2' => 123, ); - $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); + $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); $contributions = $this->callAPISuccess('contribution', 'get', array( 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1, @@ -289,7 +289,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'frequency_unit' => 'month', ); - $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); + $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); $contribution = $this->callAPISuccess('contribution', 'getsingle', array( 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 1, @@ -351,7 +351,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { 'frequency_unit' => 'month', ); - $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL, 'Submit'); + $this->callAPIAndDocument('contribution_page', 'submit', $submitParams, __FUNCTION__, __FILE__, 'submit contribution page', NULL); $contribution = $this->callAPISuccess('contribution', 'getsingle', array( 'contribution_page_id' => $this->_ids['contribution_page'], 'contribution_status_id' => 2, diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 96dba20f96..5945234b5c 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -369,7 +369,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { ); $description = "Demonstrates retrieving metadata with custom field options."; $subfile = "GetFieldsOptions"; - $fields = $this->callAPIAndDocument('contact', 'getfields', $getFieldsParams, __FUNCTION__, 'ContactTest.php', $description, $subfile, 'GetFields'); + $fields = $this->callAPIAndDocument('contact', 'getfields', $getFieldsParams, __FUNCTION__, 'ContactTest.php', $description, $subfile); $this->assertArrayHasKey('options', $fields['values']['custom_' . $customField['id']]); $this->assertEquals('Label1', $fields['values']['custom_' . $customField['id']]['options'][1]); $getOptionsArray = array( @@ -377,7 +377,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { ); $description = "Demonstrates retrieving options for a custom field."; $subfile = "GetOptions"; - $result = $this->callAPIAndDocument('contact', 'getoptions', $getOptionsArray, __FUNCTION__, 'ContactTest.php', $description, '', 'getoptions'); + $result = $this->callAPIAndDocument('contact', 'getoptions', $getOptionsArray, __FUNCTION__, 'ContactTest.php', $description, ''); $this->assertEquals('Label1', $result['values'][1]); } diff --git a/tests/phpunit/api/v3/CustomValueTest.php b/tests/phpunit/api/v3/CustomValueTest.php index 95d0437275..24292deed8 100644 --- a/tests/phpunit/api/v3/CustomValueTest.php +++ b/tests/phpunit/api/v3/CustomValueTest.php @@ -108,7 +108,7 @@ class api_v3_CustomValueTest extends CiviUnitTestCase { $result = $this->callAPIAndDocument('CustomValue', 'Get', $params, __FUNCTION__, __FILE__, $description); $params['format.field_names'] = 1; - $resultformatted = $this->callAPIAndDocument('CustomValue', 'Get', $params, __FUNCTION__, __FILE__, "utilises field names", 'formatFieldName'); + $resultformatted = $this->callAPIAndDocument('CustomValue', 'Get', $params, __FUNCTION__, __FILE__, "utilises field names", 'FormatFieldName'); // delete the contact $this->callAPISuccess('contact', 'delete', array('id' => $contact_id)); $this->assertEquals('coffee', $result['values'][$secondCustomField]['2']); diff --git a/tests/phpunit/api/v3/EntityTagTest.php b/tests/phpunit/api/v3/EntityTagTest.php index 709691bb29..c149a72d85 100644 --- a/tests/phpunit/api/v3/EntityTagTest.php +++ b/tests/phpunit/api/v3/EntityTagTest.php @@ -91,7 +91,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { 'tag_id' => $this->_tagID, ); - $result = $this->callAPIAndDocument('entity_tag', 'create', $params, __FUNCTION__, __FILE__); + $result = $this->callAPISuccess('entity_tag', 'create', $params, __FUNCTION__, __FILE__); $this->assertEquals($result['added'], 1); } @@ -150,7 +150,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase { $paramsEntity = array( 'contact_id' => $contactId, ); - $entity = $this->callAPISuccess('entity_tag', 'get', $paramsEntity); + $entity = $this->callAPIAndDocument('entity_tag', 'get', $paramsEntity, __FUNCTION__, __FILE__); } public function testHouseholdEntityGet() { diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index a6f6d210cf..fa478a7b1d 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -255,7 +255,7 @@ class api_v3_EventTest extends CiviUnitTestCase { 'contact_id' => $contactID, 'event_id' => $this->_eventIds[0], )); - $currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile, 'getsingle'); + $currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile); $this->assertEquals(1, $currentEvent['is_full'], ' is full is set in line ' . __LINE__); $this->assertEquals(0, $currentEvent['available_places'], 'available places is set in line ' . __LINE__); diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index 15a5db8ba8..69d86abe8e 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -142,7 +142,7 @@ class api_v3_GroupTest extends CiviUnitTestCase { public function testgetfields() { $description = "Demonstrate use of getfields to interrogate api."; $params = array('action' => 'create'); - $result = $this->callAPIAndDocument('group', 'getfields', $params, __FUNCTION__, __FILE__, $description, 'getfields', 'getfields'); + $result = $this->callAPIAndDocument('group', 'getfields', $params, __FUNCTION__, __FILE__, $description); $this->assertEquals(1, $result['values']['is_active']['api.default']); } diff --git a/tests/phpunit/api/v3/LocBlockTest.php b/tests/phpunit/api/v3/LocBlockTest.php index 793e23ed98..b5e7b6b082 100644 --- a/tests/phpunit/api/v3/LocBlockTest.php +++ b/tests/phpunit/api/v3/LocBlockTest.php @@ -66,7 +66,7 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { 'email_id' => $email['id'], ); $description = 'Create locBlock with existing entities'; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'simpleCreate'); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description); $id = $result['id']; $this->assertEquals(1, $result['count']); $this->assertNotNull($result['values'][$id]['id']); @@ -96,7 +96,7 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { ), ); $description = "Create entities and locBlock in 1 api call."; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'createEntities'); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, 'CreateEntities'); $id = $result['id']; $this->assertEquals(1, $result['count']); @@ -106,7 +106,7 @@ class api_v3_LocBlockTest extends CiviUnitTestCase { 'return' => 'all', ); // Can't use callAPISuccess with getsingle. - $result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call', 'getEntities', 'get'); + $result = $this->callAPIAndDocument($this->_entity, 'get', $getParams, __FUNCTION__, __FILE__, 'Get entities and location block in 1 api call'); $result = array_pop($result['values']); $this->assertNotNull($result['email_id']); $this->assertNotNull($result['phone_id']); diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index d415239529..ed53da2ec1 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -340,7 +340,6 @@ class api_v3_MembershipTest extends CiviUnitTestCase { public function testGetOnlyActive() { $description = "Demonstrates use of 'filter' active_only' param."; $this->_membershipID = $this->contactMembershipCreate($this->_params); - $subfile = 'filterIsCurrent'; $params = array( 'contact_id' => $this->_contactID, 'active_only' => 1, @@ -356,7 +355,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase { ), ); - $membership = $this->callAPIAndDocument('membership', 'get', $params, __FUNCTION__, __FILE__, $description, $subfile); + $membership = $this->callAPIAndDocument('membership', 'get', $params, __FUNCTION__, __FILE__, $description, 'FilterIsCurrent'); $this->assertEquals($membership['values'][$this->_membershipID]['status_id'], $this->_membershipStatusID); $this->assertEquals($membership['values'][$this->_membershipID]['contact_id'], $this->_contactID); @@ -675,7 +674,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $params = $this->_params; $params['custom_' . $ids['custom_field_id']] = "custom string"; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, NULL, 'CreateWithCustomData'); $check = $this->callAPISuccess($this->_entity, 'get', array( 'id' => $result['id'], 'contact_id' => $this->_contactID, @@ -811,7 +810,7 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $params = $this->_params; $params['custom_' . $ids['custom_field_id']] = "custom string"; - $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); + $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, NULL, 'UpdateCustomData'); $result = $this->callAPISuccess($this->_entity, 'create', array( 'id' => $result['id'], 'custom_' . $ids['custom_field_id'] => "new custom", diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index dd0ac6166a..3e1210ffe6 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -693,7 +693,7 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { $participants = $this->callAPISuccess('Participant', 'Get', array()); $this->assertEquals($participants['count'], 3); $params = array('contact_id' => $this->_contactID2, 'api.participant.delete' => 1); - $participants = $this->callAPIAndDocument('Participant', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile, 'Get'); + $participants = $this->callAPIAndDocument('Participant', 'Get', $params, __FUNCTION__, __FILE__, $description, $subfile); $check = $this->callAPISuccess('participant', 'getcount', array()); $this->assertEquals(1, $check, "only one participant should be left. line " . __LINE__); } diff --git a/tests/phpunit/api/v3/SettingTest.php b/tests/phpunit/api/v3/SettingTest.php index f619dfe9a6..385142cc00 100644 --- a/tests/phpunit/api/v3/SettingTest.php +++ b/tests/phpunit/api/v3/SettingTest.php @@ -312,7 +312,7 @@ class api_v3_SettingTest extends CiviUnitTestCase { ); // we'll check it with a 'get' $description = "Shows getting a variable for all domains."; - $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetAllDomains', 'Get'); + $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetAllDomains'); $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']); $this->assertEquals(1, $result['values'][1]['uniq_email_per_site']); @@ -332,7 +332,7 @@ class api_v3_SettingTest extends CiviUnitTestCase { 'return' => array('uniq_email_per_site'), ); $description = "Shows getting a variable for specified domains."; - $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSpecifiedDomains', 'Get'); + $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSpecifiedDomains'); $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']); $this->assertEquals(0, $result['values'][1]['uniq_email_per_site']); @@ -459,7 +459,7 @@ class api_v3_SettingTest extends CiviUnitTestCase { $params = array( 'name' => 'address_format', ); - $result = $this->callAPIAndDocument('setting', 'getdefaults', $params, __FUNCTION__, __FILE__, $description, 'GetDefaults', 'getdefaults'); + $result = $this->callAPIAndDocument('setting', 'getdefaults', $params, __FUNCTION__, __FILE__, $description, 'GetDefaults'); $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']); $params = array('name' => 'mailing_format'); $result = $this->callAPISuccess('setting', 'getdefaults', $params); @@ -484,7 +484,7 @@ class api_v3_SettingTest extends CiviUnitTestCase { //make sure it's set $this->assertEquals('xyz', $result['values'][CRM_Core_Config::domainID()]['address_format']); $description = "Demonstrates reverting a parameter to default value."; - $result = $this->callAPIAndDocument('setting', 'revert', $revertParams, __FUNCTION__, __FILE__, $description, '', 'revert'); + $result = $this->callAPIAndDocument('setting', 'revert', $revertParams, __FUNCTION__, __FILE__, $description, ''); //make sure it's reverted $result = $this->callAPISuccess('setting', 'get', $params); $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']); diff --git a/tests/phpunit/api/v3/SystemTest.php b/tests/phpunit/api/v3/SystemTest.php index 3dd8419ded..beba86ad53 100644 --- a/tests/phpunit/api/v3/SystemTest.php +++ b/tests/phpunit/api/v3/SystemTest.php @@ -63,7 +63,7 @@ class api_v3_SystemTest extends CiviUnitTestCase { $this->assertEquals('abc', CRM_Core_BAO_Cache::getItem(self::TEST_CACHE_GROUP, self::TEST_CACHE_PATH)); $params = array(); - $result = $this->callAPIAndDocument('system', 'flush', $params, __FUNCTION__, __FILE__, "Flush all system caches", 'Flush', 'flush'); + $result = $this->callAPIAndDocument('system', 'flush', $params, __FUNCTION__, __FILE__, "Flush all system caches", 'Flush'); $this->assertTrue(NULL === CRM_Core_BAO_Cache::getItem(self::TEST_CACHE_GROUP, self::TEST_CACHE_PATH)); } diff --git a/tests/phpunit/api/v3/TagTest.php b/tests/phpunit/api/v3/TagTest.php index 07ab1bdbd1..c1636e6195 100644 --- a/tests/phpunit/api/v3/TagTest.php +++ b/tests/phpunit/api/v3/TagTest.php @@ -83,7 +83,7 @@ class api_v3_TagTest extends CiviUnitTestCase { */ public function testGetReturnArray() { $description = "Demonstrates use of Return as an array."; - $subfile = "getReturnArray"; + $subfile = "GetReturnArray"; $params = array( 'id' => $this->tagID, @@ -185,7 +185,7 @@ class api_v3_TagTest extends CiviUnitTestCase { public function testTagGetfields() { $description = "Demonstrate use of getfields to interrogate api."; $params = array('action' => 'create'); - $result = $this->callAPIAndDocument('tag', 'getfields', $params, __FUNCTION__, __FILE__, $description, NULL, 'getfields'); + $result = $this->callAPIAndDocument('tag', 'getfields', $params, __FUNCTION__, __FILE__, $description, NULL); $this->assertEquals('civicrm_contact', $result['values']['used_for']['api.default']); } diff --git a/tests/templates/documentFunction.tpl b/tests/templates/documentFunction.tpl index 6e1ee0bb06..43293eeda3 100644 --- a/tests/templates/documentFunction.tpl +++ b/tests/templates/documentFunction.tpl @@ -1,6 +1,6 @@ {literal}