Merge pull request #2704 from jitendrapurohit/CRM_TestFix
[civicrm-core.git] / api / v3 / examples / Contact / FormatIsSuccess_Fail.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using contact create API
4 * This demonstrates use of the 'format.is_success' param.
5 This param causes only the success or otherwise of the function to be returned as BOOLEAN *
6a488035
TO
6 */
7function contact_create_example(){
edb0d67a 8$params = array(
6a488035
TO
9 'id' => 500,
10 'format.is_success' => 1,
11);
12
fb32de45 13try{
14 $result = civicrm_api3('contact', 'create', $params);
15}
16catch (CiviCRM_API3_Exception $e) {
17 // handle error here
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
22}
6a488035 23
fb32de45 24return $result;
6a488035
TO
25}
26
fb32de45 27/**
6a488035
TO
28 * Function returns array of result expected from previous function
29 */
30function contact_create_expectedresult(){
31
32 $expectedResult = 0;
33
fb32de45 34 return $expectedResult;
6a488035
TO
35}
36
37
38/*
39* This example has been generated from the API test suite. The test that created it is called
40*
41* testContactCreateFormatIsSuccessFalse and can be found in
69d79249 42* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
6a488035
TO
43*
44* You can see the outcome of the API tests at
69d79249 45* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
46*
47* To Learn about the API read
69d79249 48* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 49*
69d79249
E
50* Browse the api on your own site with the api explorer
51* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
52*
53* Read more about testing here
54* http://wiki.civicrm.org/confluence/display/CRM/Testing
55*
56* API Standards documentation:
57* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 58*/