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