| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class Participant |
| 5 | */ |
| 6 | class Participant extends PHPUnit_Framework_Testcase { |
| 7 | /** |
| 8 | * Helper function to create a Participant. |
| 9 | * |
| 10 | * @param int $contactId |
| 11 | * @param int $eventId |
| 12 | * |
| 13 | * @return int |
| 14 | * id of created Participant |
| 15 | */ |
| 16 | public static function create($contactId, $eventId) { |
| 17 | $params = array( |
| 18 | 'send_receipt' => 1, |
| 19 | 'is_test' => 0, |
| 20 | 'is_pay_later' => 0, |
| 21 | 'event_id' => $eventId, |
| 22 | 'register_date' => date('Y-m-d') . " 00:00:00", |
| 23 | 'role_id' => 1, |
| 24 | 'status_id' => 1, |
| 25 | 'source' => 'Event_' . $eventId, |
| 26 | 'contact_id' => $contactId, |
| 27 | ); |
| 28 | |
| 29 | require_once 'CRM/Event/BAO/Participant.php'; |
| 30 | $participant = CRM_Event_BAO_Participant::add($params); |
| 31 | return $participant->id; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Helper function to delete a participant. |
| 36 | * |
| 37 | * @param int $participantId |
| 38 | * @return bool |
| 39 | * true if participant deleted, false otherwise |
| 40 | */ |
| 41 | public static function delete($participantId) { |
| 42 | require_once 'CRM/Event/BAO/Participant.php'; |
| 43 | return CRM_Event_BAO_Participant::deleteParticipant($participantId); |
| 44 | } |
| 45 | |
| 46 | } |