From 54df7b0b4b4ab80a20cb7893d7eea3b708de66d5 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 30 Apr 2020 16:19:34 +1200 Subject: [PATCH] dev/core#1729 Fix filters skipping onn activity report --- CRM/Report/Form/Activity.php | 2 +- tests/phpunit/api/v3/ReportTemplateTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index ed95a7722c..cdaf918dfa 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -542,7 +542,7 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { } else { $op = $this->_params["{$fieldName}_op"] ?? NULL; - if ($op && !($fieldName == "contact_{$recordType}" && ($op != 'nnll' || $op != 'nll'))) { + if ($op && !($fieldName === "contact_{$recordType}" && ($op === 'nnll' || $op === 'nll'))) { $clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index 6316cde92e..94bb75e412 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -1259,6 +1259,23 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->assertEmpty($rowsWithNullTarget); } + /** + * Test the source contact filter works. + * + * @throws \CRM_Core_Exception + */ + public function testActivityDetailsContactFilter() { + $this->createContactsWithActivities(); + $params = [ + 'report_id' => 'activity', + 'contact_source_op' => 'has', + 'contact_source_value' => 'z', + 'options' => ['metadata' => ['sql']], + ]; + $rows = $this->callAPISuccess('report_template', 'getrows', $params); + $this->assertContains("civicrm_contact_source.sort_name LIKE '%z%'", $rows['metadata']['sql'][3]); + } + /** * Set up some activity data..... use some chars that challenge our utf handling. */ -- 2.25.1