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