6 class CRM_Event_BAO_QueryTest
extends CiviUnitTestCase
{
8 public function setUp() {
13 * Test searching for participant note.
15 * @throws \CRM_Core_Exception
17 public function testParticipantNote() {
18 $event = $this->eventCreate();
19 $this->individualCreate([
20 'api.participant.create' => [
21 'event_id' => $event['id'],
22 'note' => 'some_note',
25 $this->individualCreate([
26 'api.participant.create' => [
27 'event_id' => $event['id'],
28 'note' => 'some_other_note',
33 0 => 'participant_note',
41 $query = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query
::MODE_CONTACTS
);
42 $sql = $query->query(FALSE);
43 $result = CRM_Core_DAO
::executeQuery(implode(' ', $sql));
44 $this->assertEquals(1, $result->N
);
48 * Unit test to check if participant search retrieves correct event type id.
50 * @throws \CRM_Core_Exception
52 public function testEventType() {
53 $event = $this->eventCreate();
54 $contactId = $this->individualCreate([
55 'api.participant.create' => [
56 'event_id' => $event['id'],
75 $query = new CRM_Contact_BAO_Query(
76 $params, $returnProperties, NULL,
77 FALSE, FALSE, CRM_Contact_BAO_Query
::MODE_EVENT
79 $sql = $query->query(FALSE);
80 $result = CRM_Core_DAO
::executeQuery(implode(' ', $sql));
82 $this->assertEquals(1, $result->N
);
85 $this->assertEquals($contactId, $result->contact_id
);
86 $this->assertEquals($event['id'], $result->event_id
);
87 $eventTypeId = $this->callAPISuccessGetValue('Event', [
89 'return' => 'event_type_id',
91 $this->assertEquals($eventTypeId, $result->event_type_id
);
95 * Test provided event search parameters.
97 * @dataProvider getEventSearchParameters
99 * @throws \CRM_Core_Exception
101 public function testParameters($parameters, $expected) {
102 $query = new CRM_Contact_BAO_Query(
103 $parameters, NULL, NULL,
104 FALSE, FALSE, CRM_Contact_BAO_Query
::MODE_EVENT
106 $query->query(FALSE);
107 $this->assertEquals($expected['where'], trim($query->_whereClause
));
108 $this->assertEquals($expected['qill'], trim($query->_qill
[0][0]));
114 public function getEventSearchParameters() {
117 [['participant_status_id', '=', 1, 0, 0]],
119 'where' => '( civicrm_participant.status_id = 1 )',
120 'qill' => 'Participant Status (ID) = Registered',
124 [['participant_status_id', 'IN', [1, 2], 0, 0]],
126 'where' => '( civicrm_participant.status_id IN ("1", "2") )',
127 'qill' => 'Participant Status (ID) In Registered, Attended',