From 9670eb8521741c2dfe8e179a62ef2c3c929eb9fa Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 6 Feb 2023 16:49:26 +1300 Subject: [PATCH] Add extra test, comment how it could be used to fix bug I was working on fixing the ongoing log noise in the tested scenario - but the first PR https://github.com/civicrm/civicrm-core/pull/25392 is still pending so I decided just to put up the test with the sign posts so at least that part is done for the next time someone tries (I know that people have tried in the past) --- CRM/Contact/Selector.php | 6 +++ .../CRM/Contact/Form/Search/BasicTest.php | 39 +++++++++++++++++++ tests/phpunit/CiviTest/CiviUnitTestCase.php | 4 ++ 3 files changed, 49 insertions(+) create mode 100644 tests/phpunit/CRM/Contact/Form/Search/BasicTest.php diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index cb85daa4f2..54282ce74b 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -1025,6 +1025,12 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se * @param int $start * @param int $end * + * @todo - use test cover in CRM_Contact_Form_Search_BasicTest to + * to remove the extraneous logging that happens in the tested + * scenario (It does the catch & then write to the log - I was + * going to fix but got stalled on getting https://github.com/civicrm/civicrm-core/pull/25392 + * merged - this comment won't conflict with that PR :-) + * * @throws \CRM_Core_Exception */ public function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = self::CACHE_SIZE) { diff --git a/tests/phpunit/CRM/Contact/Form/Search/BasicTest.php b/tests/phpunit/CRM/Contact/Form/Search/BasicTest.php new file mode 100644 index 0000000000..ee7953fde9 --- /dev/null +++ b/tests/phpunit/CRM/Contact/Form/Search/BasicTest.php @@ -0,0 +1,39 @@ +getFormObject('CRM_Contact_Form_Search_Basic'); + $form->setAction(CRM_Core_Action::BASIC); + // Order by the 5th field (ie country) descending. + $_GET['crmSID'] = '5_d'; + $form->preProcess(); + $form->buildQuickForm(); + $form->postProcess(); + } + +} diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 21115e2c03..0d458f10ac 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -3226,6 +3226,10 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { $_SESSION['_' . $form->controller->_name . '_container']['values']['Preview'] = $formValues; return $form; + case strpos($class, 'Search') !== FALSE: + $form->controller = new CRM_Contact_Controller_Search(); + break; + case strpos($class, '_Form_') !== FALSE: $form->controller = new CRM_Core_Controller_Simple($class, $pageName); break; -- 2.25.1