test for new Individual form
authordemeritcowboy <demeritcowboy@hotmail.com>
Tue, 14 Jul 2020 19:29:12 +0000 (15:29 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Tue, 14 Jul 2020 19:29:12 +0000 (15:29 -0400)
tests/phpunit/CRM/Contact/Form/IndividualTest.php [new file with mode: 0644]

diff --git a/tests/phpunit/CRM/Contact/Form/IndividualTest.php b/tests/phpunit/CRM/Contact/Form/IndividualTest.php
new file mode 100644 (file)
index 0000000..fbe851b
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Class CRM_Contact_Form_IndividualTest
+ * @group headless
+ */
+class CRM_Contact_Form_IndividualTest extends CiviUnitTestCase {
+
+  /**
+   * Similar to tests in CRM_Core_FormTest where it's just testing there's no
+   * red boxes when you open the form, but Individual is more complicated.
+   *
+   * 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 in the form so it has a typo, and then this test will throw an
+   * exception.
+   */
+  public function testOpeningNewIndividualForm() {
+    $form = new CRM_Contact_Form_Contact();
+    $form->controller = new CRM_Core_Controller_Simple('CRM_Contact_Form_Contact', 'New Individual');
+
+    $form->set('reset', '1');
+    $form->set('ct', 'Individual');
+
+    ob_start();
+    $form->controller->_actions['display']->perform($form, 'display');
+    $contents = ob_get_contents();
+    ob_end_clean();
+    print_r($contents);
+
+    // 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->assertStringContainsString('<label for="first_name">', $contents);
+  }
+
+}