7646baed |
1 | <?php |
2 | require_once 'CiviTest/CiviCaseTestCase.php'; |
3 | |
4 | /** |
5 | * Class CRM_Case_Form_SearchTest |
6 | * @group headless |
7 | */ |
8 | class CRM_Case_Form_SearchTest extends CiviCaseTestCase { |
9 | |
5d345864 |
10 | public function setUp():void { |
7646baed |
11 | parent::setUp(); |
12 | $this->quickCleanup(['civicrm_case_contact', 'civicrm_case', 'civicrm_contact']); |
13 | } |
14 | |
15 | /** |
16 | * Similar to tests in CRM_Core_FormTest where it's just testing there's no |
17 | * red boxes when you open the form, but it requires CiviCase to be |
18 | * enabled so putting in a separate place. |
19 | * |
20 | * This doesn't test much expected output just that the page opens without |
21 | * notices or errors. For example to make it fail change the spelling of a |
22 | * variable so it has a typo in CRM_Case_Form_Search::preProcess(), and then |
23 | * this test will throw an exception. |
24 | */ |
25 | public function testOpeningFindCaseForm() { |
26 | $form = new CRM_Case_Form_Search(); |
27 | $form->controller = new CRM_Case_Controller_Search('Find Cases'); |
28 | |
29 | ob_start(); |
30 | $form->controller->_actions['display']->perform($form, 'display'); |
31 | $contents = ob_get_contents(); |
32 | ob_end_clean(); |
33 | |
34 | // There's a bunch of other stuff we could check for in $contents, but then |
35 | // it's tied to the html output and has the same maintenance problems |
36 | // as webtests. Mostly what we're doing in this test is checking that it |
37 | // doesn't generate any E_NOTICES/WARNINGS or other errors. But let's do |
38 | // one check. |
275686a3 |
39 | $this->assertStringContainsString('<label for="case_id">', $contents); |
7646baed |
40 | } |
41 | |
42 | } |