Merge pull request #4622 from civicrm/4.5
[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 *
2a6da8d7
EM
10 * @param $contactId
11 * @param $eventId
12 *
13 * @return mixed $participant id of created Participant
6a488035
TO
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 *
2a6da8d7
EM
36 * @param $participantId
37 * @internal param int $participantID id of the participant to delete
6a488035
TO
38 * @return boolean true if participant deleted, false otherwise
39 */
40 static function delete($participantId) {
41 require_once 'CRM/Event/BAO/Participant.php';
42 return CRM_Event_BAO_Participant::deleteParticipant($participantId);
43 }
44}