Merge pull request #4686 from lcdservices/CRM-15698-b
[civicrm-core.git] / tests / phpunit / CiviTest / Participant.php
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 mixed $participant id of created Participant
14 */
15 static function create($contactId, $eventId) {
16 $params = array(
17 'send_receipt' => 1,
18 'is_test' => 0,
19 'is_pay_later' => 0,
20 'event_id' => $eventId,
21 'register_date' => date('Y-m-d') . " 00:00:00",
22 'role_id' => 1,
23 'status_id' => 1,
24 'source' => 'Event_' . $eventId,
25 'contact_id' => $contactId,
26 );
27
28 require_once 'CRM/Event/BAO/Participant.php';
29 $participant = CRM_Event_BAO_Participant::add($params);
30 return $participant->id;
31 }
32
33 /**
34 * Helper function to delete a participant
35 *
36 * @param int $participantId
37 * @return boolean true if participant deleted, false otherwise
38 */
39 static function delete($participantId) {
40 require_once 'CRM/Event/BAO/Participant.php';
41 return CRM_Event_BAO_Participant::deleteParticipant($participantId);
42 }
43 }