Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1894 - Make CRM_Activity_Form_SearchTest::testQill less time-sensitive #17902

Merged
merged 1 commit into from
Jul 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions tests/phpunit/CRM/Activity/Form/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,55 +66,49 @@ public function testSearch() {

/**
* Test the Qill for activity Date time.
*
* @dataProvider getSearchCriteria
*
* @param array $searchCriteria
* @param array $expectedQill
*/
public function testQill($searchCriteria, $expectedQill) {
$selector = new CRM_Activity_Selector_Search($searchCriteria);
$this->assertEquals($expectedQill, $selector->getQILL());
public function testQill() {
foreach ($this->getSearchCriteria() as $test_name => $data) {
$selector = new CRM_Activity_Selector_Search($data['search_criteria']);
$this->assertEquals($data['expected_qill'], $selector->getQILL(), "Failed for data set: $test_name");
}
}

/**
* Get criteria for activity testing.
*/
public function getSearchCriteria() {

// We have to define format because tests crash trying to access the config param from the dataProvider
// perhaps because there is no property on config?
$format = '%B %E%f, %Y %l:%M %P';
$format = \Civi::settings()->get('dateformatDatetime');
$dates['ending_60.day'] = CRM_Utils_Date::getFromTo('ending_60.day', NULL, NULL);
$dates['earlier.year'] = CRM_Utils_Date::getFromTo('earlier.year', NULL, NULL);
$dates['greater.year'] = CRM_Utils_Date::getFromTo('greater.year', NULL, NULL);
return [
[
'last 60' => [
'search_criteria' => [
['activity_date_time_relative', '=', 'ending_60.day', 0, 0],
],
'expected_qill' => [['Activity Date is Last 60 days including today (between ' . CRM_Utils_Date::customFormat($dates['ending_60.day'][0], $format) . ' and ' . CRM_Utils_Date::customFormat($dates['ending_60.day'][1], $format) . ')']],
],
[
'end of previous year' => [
'search_criteria' => [
['activity_date_time_relative', '=', 'earlier.year', 0, 0],
],
'expected_qill' => [['Activity Date is To end of previous calendar year (to ' . CRM_Utils_Date::customFormat($dates['earlier.year'][1], $format) . ')']],
],
[
'start of current year' => [
'search_criteria' => [
['activity_date_time_relative', '=', 'greater.year', 0, 0],
],
'expected_qill' => [['Activity Date is From start of current calendar year (from ' . CRM_Utils_Date::customFormat($dates['greater.year'][0], $format) . ')']],
],
[
'between' => [
'search_criteria' => [
['activity_date_time_low', '=', '2019-03-05', 0, 0],
['activity_date_time_high', '=', '2019-03-27', 0, 0],
],
'expected_qill' => [['Activity Date - greater than or equal to "March 5th, 2019 12:00 AM" AND less than or equal to "March 27th, 2019 11:59 PM"']],
],
[
'status is one of' => [
'search_criteria' => [
['activity_status_id', '=', ['IN' => ['1', '2']], 0, 0],
],
Expand Down