Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using grant create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function grant_create_example(){ | |
53ca8fd7 | 7 | $params = array( |
6a488035 TO |
8 | 'contact_id' => 3, |
9 | 'application_received_date' => 'now', | |
10 | 'decision_date' => 'next Monday', | |
11 | 'amount_total' => '500', | |
12 | 'status_id' => 1, | |
13 | 'rationale' => 'Just Because', | |
14 | 'currency' => 'USD', | |
15 | 'grant_type_id' => 1, | |
16 | ); | |
17 | ||
fb32de45 | 18 | try{ |
19 | $result = civicrm_api3('grant', 'create', $params); | |
20 | } | |
21 | catch (CiviCRM_API3_Exception $e) { | |
22 | // handle error here | |
23 | $errorMessage = $e->getMessage(); | |
24 | $errorCode = $e->getErrorCode(); | |
25 | $errorData = $e->getExtraParams(); | |
26 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
27 | } | |
6a488035 | 28 | |
fb32de45 | 29 | return $result; |
6a488035 TO |
30 | } |
31 | ||
fb32de45 | 32 | /** |
6a488035 TO |
33 | * Function returns array of result expected from previous function |
34 | */ | |
35 | function grant_create_expectedresult(){ | |
36 | ||
53ca8fd7 | 37 | $expectedResult = array( |
6a488035 TO |
38 | 'is_error' => 0, |
39 | 'version' => 3, | |
40 | 'count' => 1, | |
41 | 'id' => 1, | |
53ca8fd7 | 42 | 'values' => array( |
43 | '1' => array( | |
6a488035 TO |
44 | 'id' => '1', |
45 | 'contact_id' => '3', | |
fb32de45 | 46 | 'application_received_date' => '20130728084957', |
9f1b81e0 | 47 | 'decision_date' => '20130805000000', |
6a488035 TO |
48 | 'money_transfer_date' => '', |
49 | 'grant_due_date' => '', | |
50 | 'grant_report_received' => '', | |
51 | 'grant_type_id' => '1', | |
52 | 'amount_total' => '500', | |
53 | 'amount_requested' => '', | |
54 | 'amount_granted' => '', | |
55 | 'currency' => 'USD', | |
56 | 'rationale' => 'Just Because', | |
57 | 'status_id' => '1', | |
58 | 'financial_type_id' => '', | |
59 | ), | |
60 | ), | |
61 | ); | |
62 | ||
fb32de45 | 63 | return $expectedResult; |
6a488035 TO |
64 | } |
65 | ||
66 | ||
67 | /* | |
68 | * This example has been generated from the API test suite. The test that created it is called | |
69 | * | |
70 | * testCreateGrant and can be found in | |
71 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/GrantTest.php | |
72 | * | |
73 | * You can see the outcome of the API tests at | |
74 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
75 | * | |
76 | * To Learn about the API read | |
77 | * http://book.civicrm.org/developer/current/techniques/api/ | |
78 | * | |
79 | * and review the wiki at | |
80 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
81 | * | |
82 | * Read more about testing here | |
83 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
84 | * | |
85 | * API Standards documentation: | |
86 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
87 | */ |