From 63ae2e7bcaa2516ffe7742fee17b0ddec53311cd Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 27 Feb 2019 16:48:40 +1300 Subject: [PATCH] [minor cleanup] reduce params passed to searchQuery Where we are retrieving the sql we can call the inner function rather than passing 'true' in other cases we are passing default values through --- CRM/Contact/Selector.php | 4 ++-- tests/phpunit/CRM/Contact/BAO/QueryTest.php | 25 +++++---------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index b11e19e6e3..9c3c63eb8e 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -1028,8 +1028,8 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se } // For core searches use the searchQuery method else { - $sql = $this->_query->searchQuery($start, $end, $sort, FALSE, $this->_query->_includeContactIds, - FALSE, TRUE, TRUE); + $sql = $this->_query->getSearchSQL($start, $end, $sort, FALSE, $this->_query->_includeContactIds, + FALSE, TRUE); } // CRM-9096 diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index 507069f784..1f94137f69 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -99,10 +99,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); try { - $resultDAO = $queryObj->searchQuery(0, 0, NULL, - FALSE, FALSE, - FALSE, FALSE, - FALSE); + $resultDAO = $queryObj->searchQuery(); $this->assertTrue($resultDAO->fetch()); } catch (PEAR_Exception $e) { @@ -141,10 +138,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); try { - $resultDAO = $queryObj->searchQuery(0, 0, NULL, - FALSE, FALSE, - FALSE, FALSE, - FALSE); + $resultDAO = $queryObj->searchQuery(); $this->assertFalse($resultDAO->fetch()); } catch (PEAR_Exception $e) { @@ -189,10 +183,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { ); $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); - $resultDAO = $queryObj->searchQuery(0, 0, NULL, - FALSE, FALSE, - FALSE, FALSE, - FALSE); + $resultDAO = $queryObj->searchQuery(); if ($searchPrimary) { $this->assertEquals($resultDAO->N, 0); @@ -247,10 +238,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); - $resultDAO = $queryObj->searchQuery(0, 0, NULL, - FALSE, FALSE, - FALSE, FALSE, - FALSE); + $resultDAO = $queryObj->searchQuery(); $resultDAO->fetch(); } @@ -282,10 +270,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase { $expectedSQL = "SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, civicrm_address.id as address_id, " . $selectClause . " FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE ( ( " . $whereClause . " ) ) AND (contact_a.is_deleted = 0) ORDER BY `contact_a`.`sort_name` ASC, `contact_a`.`id` "; $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties); try { - $this->assertEquals($expectedSQL, $queryObj->searchQuery(0, 0, NULL, - FALSE, FALSE, - FALSE, FALSE, - TRUE)); + $this->assertEquals($expectedSQL, $queryObj->getSearchSQL()); list($select, $from, $where, $having) = $queryObj->query(); $dao = CRM_Core_DAO::executeQuery("$select $from $where $having"); $dao->fetch(); -- 2.25.1