Merge pull request #1381 from colemanw/ccJs
[civicrm-core.git] / api / v3 / examples / NoteCreate.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using note create API
4 * *
6a488035
TO
5 */
6function 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 16try{
17 $result = civicrm_api3('note', 'create', $params);
18}
19catch (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 27return $result;
6a488035
TO
28}
29
fb32de45 30/**
6a488035
TO
31 * Function returns array of result expected from previous function
32 */
33function 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
62* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/NoteTest.php
63*
64* You can see the outcome of the API tests at
65* http://tests.dev.civicrm.org/trunk/results-api_v3
66*
67* To Learn about the API read
68* http://book.civicrm.org/developer/current/techniques/api/
69*
70* and review the wiki at
71* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
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*/