Merge pull request #4939 from colemanw/CRM-15789
[civicrm-core.git] / tests / phpunit / CiviTest / Participant.php
CommitLineData
6a488035 1<?php
aba1cd8b
EM
2
3/**
4 * Class Participant
5 */
6a488035
TO
6class Participant extends PHPUnit_Framework_Testcase {
7 /**
8 * Helper function to create a Participant
9 *
100fef9d
CW
10 * @param int $contactId
11 * @param int $eventId
2a6da8d7 12 *
72b3a70c
CW
13 * @return int
14 * id of created Participant
6a488035 15 */
00be9182 16 public static function create($contactId, $eventId) {
6a488035
TO
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 *
c490a46a 37 * @param int $participantId
a6c01b45
CW
38 * @return boolean
39 * true if participant deleted, false otherwise
6a488035 40 */
00be9182 41 public static function delete($participantId) {
6a488035
TO
42 require_once 'CRM/Event/BAO/Participant.php';
43 return CRM_Event_BAO_Participant::deleteParticipant($participantId);
44 }
45}