Merge pull request #4947 from eileenmcnaughton/examples
[civicrm-core.git] / api / v3 / examples / ParticipantStatusType / Create.php
1 <?php
2 /**
3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6 */
7
8 /**
9 * Test Generated example of using participant_status_type create API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15 function participant_status_type_create_example() {
16 $params = array(
17 'name' => 'test status',
18 'label' => 'I am a test',
19 'class' => 'Positive',
20 'is_reserved' => 0,
21 'is_active' => 1,
22 'is_counted' => 1,
23 'visibility_id' => 1,
24 'weight' => 10,
25 );
26
27 try{
28 $result = civicrm_api3('participant_status_type', 'create', $params);
29 }
30 catch (CiviCRM_API3_Exception $e) {
31 // Handle error here.
32 $errorMessage = $e->getMessage();
33 $errorCode = $e->getErrorCode();
34 $errorData = $e->getExtraParams();
35 return array(
36 'error' => $errorMessage,
37 'error_code' => $errorCode,
38 'error_data' => $errorData,
39 );
40 }
41
42 return $result;
43 }
44
45 /**
46 * Function returns array of result expected from previous function.
47 *
48 * @return array
49 * API result array
50 */
51 function participant_status_type_create_expectedresult() {
52
53 $expectedResult = array(
54 'is_error' => 0,
55 'version' => 3,
56 'count' => 1,
57 'id' => 16,
58 'values' => array(
59 '16' => array(
60 'id' => '16',
61 'name' => 'test status',
62 'label' => 'I am a test',
63 'class' => '14',
64 'is_reserved' => 0,
65 'is_active' => '1',
66 'is_counted' => '1',
67 'weight' => '10',
68 'visibility_id' => '1',
69 ),
70 ),
71 );
72
73 return $expectedResult;
74 }
75
76 /**
77 * This example has been generated from the API test suite.
78 * The test that created it is called
79 * testCreateParticipantStatusType
80 * and can be found in
81 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ParticipantStatusTypeTest.php
82 *
83 * You can see the outcome of the API tests at
84 * https://test.civicrm.org/job/CiviCRM-master-git/
85 *
86 * To Learn about the API read
87 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
88 *
89 * Browse the api on your own site with the api explorer
90 * http://MYSITE.ORG/path/to/civicrm/api/explorer
91 *
92 * Read more about testing here
93 * http://wiki.civicrm.org/confluence/display/CRM/Testing
94 *
95 * API Standards documentation:
96 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
97 */