* @throws \Exception
*/
public function testSelectorQuery($dataSet) {
+ $tag = $this->callAPISuccess('Tag', 'create', [
+ 'name' => 'Test Tag Name' . uniqid(),
+ 'parent_id' => 1,
+ ]);
if (!empty($dataSet['limitedPermissions'])) {
CRM_Core_Config::singleton()->userPermissionClass->permissions = [
'access CiviCRM',
foreach ($dataSet['expected_query'] as $index => $queryString) {
$this->assertLike($this->strWrangle($queryString), $this->strWrangle($sql[$index]));
}
+ if (!empty($dataSet['where_contains'])) {
+ $this->assertContains($this->strWrangle(str_replace('@tagid', $tag['id'], $dataSet['where_contains'])), $this->strWrangle($sql[2]));
+ }
// Ensure that search builder return individual contact as per criteria
if ($dataSet['context'] === 'builder') {
$contactID = $this->individualCreate(['first_name' => 'James', 'last_name' => 'Bond']);
$this->assertEquals($contactID, $rows[0]['source_contact_id']);
}
else {
+ $this->callAPISuccess('EntityTag', 'create', [
+ 'entity_id' => $contactID,
+ 'tag_id' => $tag['id'],
+ 'entity_table' => 'civicrm_contact',
+ ]);
$this->callAPISuccess('Address', 'create', [
'contact_id' => $contactID,
'location_type_id' => 'Home',
if (!empty($dataSet['limitedPermissions'])) {
$this->cleanUpAfterACLs();
}
+ $this->callAPISuccess('Tag', 'delete', ['id' => $tag['id']]);
}
/**
'expected_query' => [],
],
],
+ [
+ [
+ 'description' => 'Tag Equals Test',
+ 'class' => 'CRM_Contact_Selector',
+ 'settings' => [],
+ 'form_values' => [['contact_type', '=', 'Individual', 1, 0], ['tag', '=', '1', 1, 0]],
+ 'params' => [],
+ 'return_properties' => NULL,
+ 'context' => 'builder',
+ 'action' => CRM_Core_Action::NONE,
+ 'includeContactIds' => NULL,
+ 'searchDescendentGroups' => FALSE,
+ 'expected_query' => [],
+ 'where_contains' => 'tag_id IN ( 1,@tagid )',
+ ],
+ ],
[
[
'description' => 'Normal default behaviour',