$field = CRM_Utils_Array::value($locType[0], $this->_fields);
if (!$field) {
+ // Strip any trailing _high & _low that might be appended.
+ $realFieldName = str_replace(['_high', '_low'], '', $name);
+ if (isset($this->_fields[$realFieldName])) {
+ $field = $this->_fields[str_replace(['_high', '_low'], '', $realFieldName)];
+ $this->dateQueryBuilder($values, $field['table_name'], $realFieldName, $realFieldName, $field['title']);
+ }
return;
}
}
$appendTimeStamp = TRUE,
$dateFormat = 'YmdHis'
) {
+ // @todo - remove dateFormat - pretty sure it's never passed in...
list($name, $op, $value, $grouping, $wildcard) = $values;
if ($name == "{$fieldName}_low" ||
/**
* Include dataProvider for tests
+ *
* @group headless
*/
class CRM_Contribute_BAO_QueryTest extends CiviUnitTestCase {
public function tearDown() {
$this->quickCleanUpFinancialEntities();
+ parent::tearDown();
}
/**
* order by a passed in list. It makes sense for option groups & small sets
* but may not do for long lists like states - performance testing not done on that yet.
*
+ * @throws \CRM_Core_Exception
+ *
* @dataProvider getSortFields
*/
public function testSearchPseudoReturnProperties($sort, $isUseKeySort) {
];
}
+ /**
+ * Test receive_date_high, low & relative work.
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testRelativeContributionDates() {
+ $this->contributionCreate(['receive_date' => '2018-01-02', 'contact_id' => $this->individualCreate()]);
+ $this->contributionCreate(['receive_date' => '2017-01-02', 'contact_id' => $this->individualCreate()]);
+ $queryObj = new CRM_Contact_BAO_Query([['receive_date_low', '=', 20170101, 1, 0]]);
+ $this->assertEquals(2, $queryObj->searchQuery(0, 0, NULL, TRUE));
+ $queryObj = new CRM_Contact_BAO_Query([['receive_date_low', '=', 20180101, 1, 0]]);
+ $this->assertEquals(1, $queryObj->searchQuery(0, 0, NULL, TRUE));
+ $queryObj = new CRM_Contact_BAO_Query([['receive_date_high', '=', 20180101, 1, 0]]);
+ $this->assertEquals(1, $queryObj->searchQuery(0, 0, NULL, TRUE));
+ }
+
}