From 7646baed1ba0a35fdfefb692d4ef46967f1fef68 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Mon, 15 Jun 2020 10:33:02 -0400 Subject: [PATCH] test for case search form --- tests/phpunit/CRM/Case/Form/SearchTest.php | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/phpunit/CRM/Case/Form/SearchTest.php diff --git a/tests/phpunit/CRM/Case/Form/SearchTest.php b/tests/phpunit/CRM/Case/Form/SearchTest.php new file mode 100644 index 0000000000..42c499d2aa --- /dev/null +++ b/tests/phpunit/CRM/Case/Form/SearchTest.php @@ -0,0 +1,42 @@ +quickCleanup(['civicrm_case_contact', 'civicrm_case', 'civicrm_contact']); + } + + /** + * Similar to tests in CRM_Core_FormTest where it's just testing there's no + * red boxes when you open the form, but it requires CiviCase to be + * enabled so putting in a separate place. + * + * This doesn't test much expected output just that the page opens without + * notices or errors. For example to make it fail change the spelling of a + * variable so it has a typo in CRM_Case_Form_Search::preProcess(), and then + * this test will throw an exception. + */ + public function testOpeningFindCaseForm() { + $form = new CRM_Case_Form_Search(); + $form->controller = new CRM_Case_Controller_Search('Find Cases'); + + ob_start(); + $form->controller->_actions['display']->perform($form, 'display'); + $contents = ob_get_contents(); + ob_end_clean(); + + // There's a bunch of other stuff we could check for in $contents, but then + // it's tied to the html output and has the same maintenance problems + // as webtests. Mostly what we're doing in this test is checking that it + // doesn't generate any E_NOTICES/WARNINGS or other errors. But let's do + // one check. + $this->assertContains('