Update test examples.
[civicrm-core.git] / api / v3 / examples / Case / Create.php
CommitLineData
ceb6db34 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Case.create API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function case_create_example() {
9 $params = array(
10 'subject' => 'Test case',
11 'contact_id' => 17,
12 'case_type' => 'housing_support',
13 );
ceb6db34 14
50fb255d 15 try{
a828d7b8 16 $result = civicrm_api3('Case', 'create', $params);
50fb255d 17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array(
5be22f39 24 'is_error' => 1,
25 'error_message' => $errorMessage,
50fb255d 26 'error_code' => $errorCode,
27 'error_data' => $errorData,
28 );
29 }
30
31 return $result;
ceb6db34
E
32}
33
34/**
50fb255d 35 * Function returns array of result expected from previous function.
36 *
37 * @return array
38 * API result array
ceb6db34 39 */
50fb255d 40function case_create_expectedresult() {
ceb6db34
E
41
42 $expectedResult = array(
50fb255d 43 'is_error' => 0,
44 'version' => 3,
45 'count' => 1,
46 'id' => 2,
47 'values' => array(
89bf81b4 48 '2' => array(
50fb255d 49 'id' => '2',
50 'case_type_id' => '1',
51 'subject' => 'Test case',
52 'start_date' => '2013-07-29 00:00:00',
53 'end_date' => '',
54 'details' => '',
55 'status_id' => '1',
56 'is_deleted' => '',
57 ),
ceb6db34 58 ),
50fb255d 59 );
ceb6db34
E
60
61 return $expectedResult;
62}
63
a828d7b8 64/*
50fb255d 65* This example has been generated from the API test suite.
a828d7b8
CW
66* The test that created it is called "testCaseCreate"
67* and can be found at:
ceb6db34
E
68* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CaseTest.php
69*
70* You can see the outcome of the API tests at
71* https://test.civicrm.org/job/CiviCRM-master-git/
72*
73* To Learn about the API read
74* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
75*
76* Browse the api on your own site with the api explorer
41d4d31f 77* http://MYSITE.ORG/path/to/civicrm/api
ceb6db34
E
78*
79* Read more about testing here
80* http://wiki.civicrm.org/confluence/display/CRM/Testing
81*
82* API Standards documentation:
83* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
84*/