Merge pull request #3152 from pradpnayak/CRM-14112
[civicrm-core.git] / tests / phpunit / CiviTest / Participant.php
1 <?php
2 class Participant extends PHPUnit_Framework_Testcase {
3 /**
4 * Helper function to create a Participant
5 *
6 * @param $contactId
7 * @param $eventId
8 *
9 * @return mixed $participant id of created Participant
10 */
11 static function create($contactId, $eventId) {
12 $params = array(
13 'send_receipt' => 1,
14 'is_test' => 0,
15 'is_pay_later' => 0,
16 'event_id' => $eventId,
17 'register_date' => date('Y-m-d') . " 00:00:00",
18 'role_id' => 1,
19 'status_id' => 1,
20 'source' => 'Event_' . $eventId,
21 'contact_id' => $contactId,
22 );
23
24 require_once 'CRM/Event/BAO/Participant.php';
25 $participant = CRM_Event_BAO_Participant::add($params);
26 return $participant->id;
27 }
28
29 /**
30 * Helper function to delete a participant
31 *
32 * @param $participantId
33 * @internal param int $participantID id of the participant to delete
34 * @return boolean true if participant deleted, false otherwise
35 */
36 static function delete($participantId) {
37 require_once 'CRM/Event/BAO/Participant.php';
38 return CRM_Event_BAO_Participant::deleteParticipant($participantId);
39 }
40 }