Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed event type id fetch #14534

Merged
merged 1 commit into from
Jul 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CRM/Event/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public static function select(&$query) {
}

if (!empty($query->_returnProperties['event_type_id'])) {
$query->_select['event_type_id'] = "event_type.id as event_type_id";
$query->_select['event_type_id'] = "civicrm_event.event_type_id as event_type_id";
$query->_element['event_type_id'] = 1;
$query->_tables['event_type'] = 1;
$query->_whereTables['event_type'] = 1;
$query->_tables['civicrm_event'] = 1;
$query->_whereTables['civicrm_event'] = 1;
}

//add status_id
Expand Down
46 changes: 46 additions & 0 deletions tests/phpunit/CRM/Event/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,50 @@ public function testParticipantNote() {
$this->assertEquals(1, $result->N);
}

/**
* Unit test to check if participant search retrieves correct event type id.
*
*/
public function testEventType() {
$event = $this->eventCreate();
$contactId = $this->individualCreate([
'api.participant.create' => [
'event_id' => $event['id'],
],
]);
$params = [
[
0 => 'event_id',
1 => '=',
2 => $event['id'],
3 => 1,
4 => 0,
],
];

$returnProperties = [
'event_type_id' => 1,
'contact_id' => 1,
'event_id' => 1,
];

$query = new CRM_Contact_BAO_Query(
$params, $returnProperties, NULL,
FALSE, FALSE, CRM_Contact_BAO_Query::MODE_EVENT
);
$sql = $query->query(FALSE);
$result = CRM_Core_DAO::executeQuery(implode(' ', $sql));

$this->assertEquals(1, $result->N);
$result->fetch();

$this->assertEquals($contactId, $result->contact_id);
$this->assertEquals($event['id'], $result->event_id);
$eventTypeId = $this->callAPISuccessGetValue('Event', [
'id' => $event['id'],
'return' => 'event_type_id',
]);
$this->assertEquals($eventTypeId, $result->event_type_id);
}

}