* @param $fv
* @param $count
* @param $ids
- * @param $full
+ *
+ * @throws \CRM_Core_Exception
*/
- public function testSearch($fv, $count, $ids, $full) {
+ public function testSearch($fv, $count, $ids) {
$this->callAPISuccess('SavedSearch', 'create', ['form_values' => 'a:9:{s:5:"qfKey";s:32:"0123456789abcdef0123456789abcdef";s:13:"includeGroups";a:1:{i:0;s:1:"3";}s:13:"excludeGroups";a:0:{}s:11:"includeTags";a:0:{}s:11:"excludeTags";a:0:{}s:4:"task";s:2:"14";s:8:"radio_ts";s:6:"ts_all";s:14:"customSearchID";s:1:"4";s:17:"customSearchClass";s:36:"CRM_Contact_Form_Search_Custom_Group";}']);
$this->callAPISuccess('SavedSearch', 'create', ['form_values' => 'a:9:{s:5:"qfKey";s:32:"0123456789abcdef0123456789abcdef";s:13:"includeGroups";a:1:{i:0;s:1:"3";}s:13:"excludeGroups";a:0:{}s:11:"includeTags";a:0:{}s:11:"excludeTags";a:0:{}s:4:"task";s:2:"14";s:8:"radio_ts";s:6:"ts_all";s:14:"customSearchID";s:1:"4";s:17:"customSearchClass";s:36:"CRM_Contact_Form_Search_Custom_Group";}']);
/**
* Check that we get a successful result querying for home address.
* CRM-14263 search builder failure with search profile & address in criteria
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSearchProfileHomeCityCRM14263() {
$contactID = $this->individualCreate();
/**
* Check that we get a successful result querying for home address.
* CRM-14263 search builder failure with search profile & address in criteria
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSearchProfileHomeCityNoResultsCRM14263() {
$contactID = $this->individualCreate();
/**
* Test searchPrimaryDetailsOnly setting.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSearchPrimaryLocTypes() {
$contactID = $this->individualCreate();
/**
* Test created to prove failure of search on state when location
* display name is different form location name (issue 607)
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSearchOtherLocationUpperLower() {
* Test smart groups with non-numeric don't fail on range queries.
*
* CRM-14720
+ *
+ * @throws \CRM_Core_Exception
*/
public function testNumericPostal() {
// Precaution as hitting some inconsistent set up running in isolation vs in the suite.
/**
* Test searches are case insensitive.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testCaseInsensitive() {
$orgID = $this->organizationCreate(['organization_name' => 'BOb']);
$this->callAPISuccess('Contact', 'create', $params);
unset($params['contact_type']);
foreach ($params as $key => $value) {
- if ($key == 'employer_id') {
+ if ($key === 'employer_id') {
$searchParams = [['current_employer', '=', 'bob', 0, 1]];
}
else {
$searchParams = [[$key, '=', strtolower($value), 0, 1]];
}
- $query = new CRM_Contact_BAO_Query($searchParams);
- $result = $query->apiQuery($searchParams);
- $this->assertEquals(1, count($result[0]), 'search for ' . $key);
+
+ $result = CRM_Contact_BAO_Query::apiQuery($searchParams);
+ $this->assertCount(1, $result[0], 'search for ' . $key);
$contact = reset($result[0]);
$this->assertEquals('Minnie Mouse', $contact['display_name']);
$this->assertEquals('BOb', $contact['current_employer']);
* Test smart groups with non-numeric don't fail on equal queries.
*
* CRM-14720
+ *
+ * @throws \CRM_Core_Exception
*/
public function testNonNumericEqualsPostal() {
$this->individualCreate(['api.address.create' => ['postal_code' => 5, 'location_type_id' => 'Main']]);
}
+ /**
+ * Test relationship description.
+ *
+ * @throws \CRM_Core_Exception
+ */
public function testRelationshipDescription() {
$relType = $this->callAPISuccess('RelationshipType', 'create', [
- 'name_a_b' => uniqid('a'),
- 'name_b_a' => uniqid('b'),
+ 'name_a_b' => 'blah',
+ 'name_b_a' => 'other blah',
]);
$contactID_a = $this->individualCreate([], 1);
$contactID_b = $this->individualCreate([], 2);
// This is a little weird but seems consistent with the behavior of the search form in general.
// Technically there are 2 contacts who share a relationship with the description searched for,
// so one might expect the search form to return both of them instead of just Contact A... but it doesn't.
- $this->assertEquals('1', $dao->N, "Search query returns exactly 1 result?");
- $this->assertTrue($dao->fetch(), "Search query returns success?");
- $this->assertEquals($contactID_a, $dao->contact_id, "Search query returns contact A?");
+ $this->assertEquals('1', $dao->N, 'Search query returns exactly 1 result?');
+ $this->assertTrue($dao->fetch(), 'Search query returns success?');
+ $this->assertEquals($contactID_a, $dao->contact_id, 'Search query returns contact A?');
}
+ /**
+ * Test non-reciprocal relationship.
+ *
+ * @throws \CRM_Core_Exception
+ */
public function testNonReciprocalRelationshipTargetGroupIsCorrectResults() {
$contactID_a = $this->individualCreate();
$contactID_b = $this->individualCreate();
$this->assertContains('INNER JOIN civicrm_tmp_e', $sql, "Query appears to use temporary table of compiled relationships?", TRUE);
}
+ /**
+ * Test relationship permission clause.
+ *
+ * @throws \CRM_Core_Exception
+ */
public function testRelationshipPermissionClause() {
$params = [['relation_type_id', 'IN', ['1_b_a'], 0, 0], ['relation_permission', 'IN', [2], 0, 0]];
$sql = CRM_Contact_BAO_Query::getQuery($params);
/**
* CRM-19562 ensure that only ids are used for contact_id searching.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testContactIDClause() {
$params = [
- ["mark_x_2", "=", 1, 0, 0],
- ["mark_x_foo@example.com", "=", 1, 0, 0],
+ ['mark_x_2', '=', 1, 0, 0],
+ ['mark_x_foo@example.com', '=', 1, 0, 0],
];
$returnProperties = [
- "sort_name" => 1,
- "email" => 1,
- "do_not_email" => 1,
- "is_deceased" => 1,
- "on_hold" => 1,
- "display_name" => 1,
- "preferred_mail_format" => 1,
+ 'sort_name' => 1,
+ 'email' => 1,
+ 'do_not_email' => 1,
+ 'is_deceased' => 1,
+ 'on_hold' => 1,
+ 'display_name' => 1,
+ 'preferred_mail_format' => 1,
];
$numberOfContacts = 2;
- $query = new CRM_Contact_BAO_Query($params, $returnProperties);
+
try {
- $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberOfContacts);
+ CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, $numberOfContacts);
}
catch (Exception $e) {
$this->assertEquals(
- "One of parameters (value: foo@example.com) is not of the type Positive",
+ 'One of parameters (value: foo@example.com) is not of the type Positive',
$e->getMessage()
);
$this->assertTrue(TRUE);
* Test the sorting on the contact ID query works with a profile search.
*
* Checking for lack of fatal.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testContactIDQueryProfileSearchResults() {
$profile = $this->callAPISuccess('UFGroup', 'create', ['group_type' => 'Contact', 'name' => 'search', 'title' => 'search']);
/**
* Test the summary query does not add an acl clause when acls not enabled..
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetSummaryQueryWithFinancialACLDisabled() {
$this->createContributionsForSummaryQueryTests();
/**
* Test the summary query accurately adds financial acl filters.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testGetSummaryQueryWithFinancialACLEnabled() {
$where = $from = NULL;