Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using note create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function note_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 TO |
8 | 'entity_table' => 'civicrm_contact', |
9 | 'entity_id' => 1, | |
10 | 'note' => 'Hello!!! m testing Note', | |
11 | 'contact_id' => 1, | |
12 | 'modified_date' => '2011-01-31', | |
13 | 'subject' => 'Test Note', | |
6a488035 TO |
14 | ); |
15 | ||
fb32de45 | 16 | try{ |
17 | $result = civicrm_api3('note', '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 | } | |
6a488035 | 26 | |
fb32de45 | 27 | return $result; |
6a488035 TO |
28 | } |
29 | ||
fb32de45 | 30 | /** |
6a488035 TO |
31 | * Function returns array of result expected from previous function |
32 | */ | |
33 | function note_create_expectedresult(){ | |
34 | ||
53ca8fd7 | 35 | $expectedResult = array( |
6a488035 TO |
36 | 'is_error' => 0, |
37 | 'version' => 3, | |
38 | 'count' => 1, | |
39 | 'id' => 2, | |
53ca8fd7 | 40 | 'values' => array( |
41 | '2' => array( | |
6a488035 TO |
42 | 'id' => '2', |
43 | 'entity_table' => 'civicrm_contact', | |
44 | 'entity_id' => '1', | |
45 | 'note' => 'Hello!!! m testing Note', | |
46 | 'contact_id' => '1', | |
47 | 'modified_date' => '2012-11-14 16:02:35', | |
48 | 'subject' => 'Test Note', | |
49 | 'privacy' => 0, | |
50 | ), | |
51 | ), | |
52 | ); | |
53 | ||
fb32de45 | 54 | return $expectedResult; |
6a488035 TO |
55 | } |
56 | ||
57 | ||
58 | /* | |
59 | * This example has been generated from the API test suite. The test that created it is called | |
60 | * | |
61 | * testCreate and can be found in | |
69d79249 | 62 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/NoteTest.php |
6a488035 TO |
63 | * |
64 | * You can see the outcome of the API tests at | |
69d79249 | 65 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
66 | * |
67 | * To Learn about the API read | |
69d79249 | 68 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 69 | * |
69d79249 E |
70 | * Browse the api on your own site with the api explorer |
71 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
72 | * |
73 | * Read more about testing here | |
74 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
75 | * | |
76 | * API Standards documentation: | |
77 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 78 | */ |