$qillName = $name;
$name = 'role_id';
+ $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String';
+ $tableName = empty($tableName) ? 'civicrm_participant' : $tableName;
if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
$op = key($value);
$value = $value[$op];
$this->quickCleanup($tablesToTruncate, TRUE);
}
+ /**
+ * Test get participants with role_id.
+ */
+ public function testGetParticipantWithRole() {
+ $roleId = array(1, 2, 3);
+ foreach ($roleId as $role) {
+ $this->participantCreate(array(
+ 'contact_id' => $this->individualCreate(),
+ 'role_id' => $role,
+ 'event_id' => $this->_eventID,
+ ));
+ }
+
+ $params = array(
+ 'role_id' => 2,
+ );
+ $result = $this->callAPISuccess('participant', 'get', $params);
+ //Assert all the returned participants has a role_id of 2
+ foreach ($result['values'] as $pid => $values) {
+ $this->assertEquals($values['participant_role_id'], 2);
+ }
+
+ $this->participantCreate(array(
+ 'id' => $this->_participantID,
+ 'role_id' => NULL,
+ 'event_id' => $this->_eventID,
+ ));
+
+ $params['role_id'] = array(
+ 'IS NULL' => 1,
+ );
+ $result = $this->callAPISuccess('participant', 'get', $params);
+ foreach ($result['values'] as $pid => $values) {
+ $this->assertEquals($values['participant_role_id'], NULL);
+ }
+
+ }
+
/**
* Check with complete array + custom field
* Note that the test is written on purpose without any