Merge pull request #2714 from jitendrapurohit/CRMTestFix
[civicrm-core.git] / api / v3 / examples / Note / Create.php
1 <?php
2 /**
3 * Test Generated example of using note create API
4 * *
5 */
6 function note_create_example(){
7 $params = array(
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',
14 );
15
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 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function
32 */
33 function note_create_expectedresult(){
34
35 $expectedResult = array(
36 'is_error' => 0,
37 'version' => 3,
38 'count' => 1,
39 'id' => 2,
40 'values' => array(
41 '2' => array(
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
54 return $expectedResult;
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
62 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/NoteTest.php
63 *
64 * You can see the outcome of the API tests at
65 * https://test.civicrm.org/job/CiviCRM-master-git/
66 *
67 * To Learn about the API read
68 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
69 *
70 * Browse the api on your own site with the api explorer
71 * http://MYSITE.ORG/path/to/civicrm/api/explorer
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
78 */