| 1 | <?php |
| 2 | /** |
| 3 | * Test Generated example of using event get API |
| 4 | * * |
| 5 | */ |
| 6 | function event_get_example(){ |
| 7 | $params = array( |
| 8 | 'event_title' => 'Annual CiviCRM meet', |
| 9 | 'sequential' => true, |
| 10 | ); |
| 11 | |
| 12 | try{ |
| 13 | $result = civicrm_api3('event', 'get', $params); |
| 14 | } |
| 15 | catch (CiviCRM_API3_Exception $e) { |
| 16 | // handle error here |
| 17 | $errorMessage = $e->getMessage(); |
| 18 | $errorCode = $e->getErrorCode(); |
| 19 | $errorData = $e->getExtraParams(); |
| 20 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); |
| 21 | } |
| 22 | |
| 23 | return $result; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Function returns array of result expected from previous function |
| 28 | */ |
| 29 | function event_get_expectedresult(){ |
| 30 | |
| 31 | $expectedResult = array( |
| 32 | 'is_error' => 0, |
| 33 | 'version' => 3, |
| 34 | 'count' => 1, |
| 35 | 'id' => 1, |
| 36 | 'values' => array( |
| 37 | '0' => array( |
| 38 | 'id' => '1', |
| 39 | 'title' => 'Annual CiviCRM meet', |
| 40 | 'event_title' => 'Annual CiviCRM meet', |
| 41 | 'event_type_id' => '1', |
| 42 | 'participant_listing_id' => 0, |
| 43 | 'is_public' => '1', |
| 44 | 'start_date' => '2013-07-29 00:00:00', |
| 45 | 'event_start_date' => '2013-07-29 00:00:00', |
| 46 | 'is_online_registration' => 0, |
| 47 | 'is_monetary' => 0, |
| 48 | 'is_map' => 0, |
| 49 | 'is_active' => '1', |
| 50 | 'is_show_location' => '1', |
| 51 | 'default_role_id' => '1', |
| 52 | 'is_email_confirm' => 0, |
| 53 | 'is_pay_later' => 0, |
| 54 | 'is_partial_payment' => 0, |
| 55 | 'is_multiple_registrations' => 0, |
| 56 | 'allow_same_participant_emails' => 0, |
| 57 | 'is_template' => 0, |
| 58 | 'created_date' => '2013-07-28 08:49:19', |
| 59 | 'is_share' => '1', |
| 60 | ), |
| 61 | ), |
| 62 | ); |
| 63 | |
| 64 | return $expectedResult; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /* |
| 69 | * This example has been generated from the API test suite. The test that created it is called |
| 70 | * |
| 71 | * testGetEventByEventTitle and can be found in |
| 72 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/EventTest.php |
| 73 | * |
| 74 | * You can see the outcome of the API tests at |
| 75 | * http://tests.dev.civicrm.org/trunk/results-api_v3 |
| 76 | * |
| 77 | * To Learn about the API read |
| 78 | * http://book.civicrm.org/developer/current/techniques/api/ |
| 79 | * |
| 80 | * and review the wiki at |
| 81 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs |
| 82 | * |
| 83 | * Read more about testing here |
| 84 | * http://wiki.civicrm.org/confluence/display/CRM/Testing |
| 85 | * |
| 86 | * API Standards documentation: |
| 87 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards |
| 88 | */ |