CRM-12622 - CiviUnitTestCase - Promote sethtmlGlobals
authorTim Otten <totten@civicrm.org>
Tue, 30 Jul 2013 04:19:53 +0000 (21:19 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 30 Jul 2013 04:19:53 +0000 (21:19 -0700)
When defining multiple cases in CRM_Report_Form_Contribute_Detail, the
second case fails due to an uninitialized (lost?) global.
api_v3_UFFieldTest seems to have a work-around.

```
1) CRM_Report_Form_Contribute_DetailTest::testReportOutput with data set #1 ('CRM_Report_Form_Contribute_Detail', array(array('first_name', 'email', 'total_amount'), array('gte', 50)), 'fixtures/dataset.sql', 'fixtures/report.csv')
Undefined index: _HTML_QuickForm_registered_rules

/Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm/RuleRegistry.php:122
/Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm/RuleRegistry.php:98
/Applications/MAMP/htdocs/sites/all/modules/civicrm/packages/HTML/QuickForm.php:389
/Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Form.php:187
/Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Form.php:156
/Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Report/Form.php:256
/Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Report/Form/Contribute/Detail.php:362
/Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Controller.php:426
/Applications/MAMP/htdocs/sites/all/modules/civicrm/CRM/Core/Controller/Simple.php:79
/Applications/MAMP/htdocs/sites/all/modules/civicrm/tests/phpunit/CiviTest/CiviReportTestCase.php:43
/Applications/MAMP/htdocs/sites/all/modules/civicrm/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php:105
/Applications/MAMP/htdocs/sites/all/modules/civicrm/tools/scripts/phpunit:75
```

----------------------------------------
* CRM-12622: Create framework for example report data files
  http://issues.civicrm.org/jira/browse/CRM-12622

tests/phpunit/CiviTest/CiviReportTestCase.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/UFFieldTest.php

index 4de7a44dd81a07575454776f5e7cfdbf9ecfa2c8..5ae55cec147ff83fc0f4f6380f75834dbe77dcf4 100644 (file)
@@ -30,6 +30,7 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 class CiviReportTestCase extends CiviUnitTestCase {
   function setUp() {
     parent::setUp();
+    $this->_sethtmlGlobals();
   }
 
   function tearDown() {
index b627d381af819e1ba10337771a8e100c9ab4cfe9..307233d339c60553a5e63fefb094f83d5f531e22 100644 (file)
@@ -2267,6 +2267,178 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       }
     }
   }
+
+  /**
+   * FIXME: something NULLs $GLOBALS['_HTML_QuickForm_registered_rules'] when the tests are ran all together
+   * (NB unclear if this is still required)
+   */
+  function _sethtmlGlobals() {
+    $GLOBALS['_HTML_QuickForm_registered_rules'] = array(
+      'required' => array(
+        'html_quickform_rule_required',
+        'HTML/QuickForm/Rule/Required.php'
+      ),
+      'maxlength' => array(
+        'html_quickform_rule_range',
+        'HTML/QuickForm/Rule/Range.php'
+      ),
+      'minlength' => array(
+        'html_quickform_rule_range',
+        'HTML/QuickForm/Rule/Range.php'
+      ),
+      'rangelength' => array(
+        'html_quickform_rule_range',
+        'HTML/QuickForm/Rule/Range.php'
+      ),
+      'email' => array(
+        'html_quickform_rule_email',
+        'HTML/QuickForm/Rule/Email.php'
+      ),
+      'regex' => array(
+        'html_quickform_rule_regex',
+        'HTML/QuickForm/Rule/Regex.php'
+      ),
+      'lettersonly' => array(
+        'html_quickform_rule_regex',
+        'HTML/QuickForm/Rule/Regex.php'
+      ),
+      'alphanumeric' => array(
+        'html_quickform_rule_regex',
+        'HTML/QuickForm/Rule/Regex.php'
+      ),
+      'numeric' => array(
+        'html_quickform_rule_regex',
+        'HTML/QuickForm/Rule/Regex.php'
+      ),
+      'nopunctuation' => array(
+        'html_quickform_rule_regex',
+        'HTML/QuickForm/Rule/Regex.php'
+      ),
+      'nonzero' => array(
+        'html_quickform_rule_regex',
+        'HTML/QuickForm/Rule/Regex.php'
+      ),
+      'callback' => array(
+        'html_quickform_rule_callback',
+        'HTML/QuickForm/Rule/Callback.php'
+      ),
+      'compare' => array(
+        'html_quickform_rule_compare',
+        'HTML/QuickForm/Rule/Compare.php'
+      )
+    );
+    // FIXME: …ditto for $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']
+    $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = array(
+      'group' => array(
+        'HTML/QuickForm/group.php',
+        'HTML_QuickForm_group'
+      ),
+      'hidden' => array(
+        'HTML/QuickForm/hidden.php',
+        'HTML_QuickForm_hidden'
+      ),
+      'reset' => array(
+        'HTML/QuickForm/reset.php',
+        'HTML_QuickForm_reset'
+      ),
+      'checkbox' => array(
+        'HTML/QuickForm/checkbox.php',
+        'HTML_QuickForm_checkbox'
+      ),
+      'file' => array(
+        'HTML/QuickForm/file.php',
+        'HTML_QuickForm_file'
+      ),
+      'image' => array(
+        'HTML/QuickForm/image.php',
+        'HTML_QuickForm_image'
+      ),
+      'password' => array(
+        'HTML/QuickForm/password.php',
+        'HTML_QuickForm_password'
+      ),
+      'radio' => array(
+        'HTML/QuickForm/radio.php',
+        'HTML_QuickForm_radio'
+      ),
+      'button' => array(
+        'HTML/QuickForm/button.php',
+        'HTML_QuickForm_button'
+      ),
+      'submit' => array(
+        'HTML/QuickForm/submit.php',
+        'HTML_QuickForm_submit'
+      ),
+      'select' => array(
+        'HTML/QuickForm/select.php',
+        'HTML_QuickForm_select'
+      ),
+      'hiddenselect' => array(
+        'HTML/QuickForm/hiddenselect.php',
+        'HTML_QuickForm_hiddenselect'
+      ),
+      'text' => array(
+        'HTML/QuickForm/text.php',
+        'HTML_QuickForm_text'
+      ),
+      'textarea' => array(
+        'HTML/QuickForm/textarea.php',
+        'HTML_QuickForm_textarea'
+      ),
+      'fckeditor' => array(
+        'HTML/QuickForm/fckeditor.php',
+        'HTML_QuickForm_FCKEditor'
+      ),
+      'tinymce' => array(
+        'HTML/QuickForm/tinymce.php',
+        'HTML_QuickForm_TinyMCE'
+      ),
+      'dojoeditor' => array(
+        'HTML/QuickForm/dojoeditor.php',
+        'HTML_QuickForm_dojoeditor'
+      ),
+      'link' => array(
+        'HTML/QuickForm/link.php',
+        'HTML_QuickForm_link'
+      ),
+      'advcheckbox' => array(
+        'HTML/QuickForm/advcheckbox.php',
+        'HTML_QuickForm_advcheckbox'
+      ),
+      'date' => array(
+        'HTML/QuickForm/date.php',
+        'HTML_QuickForm_date'
+      ),
+      'static' => array(
+        'HTML/QuickForm/static.php',
+        'HTML_QuickForm_static'
+      ),
+      'header' => array(
+        'HTML/QuickForm/header.php',
+        'HTML_QuickForm_header'
+      ),
+      'html' => array(
+        'HTML/QuickForm/html.php',
+        'HTML_QuickForm_html'
+      ),
+      'hierselect' => array(
+        'HTML/QuickForm/hierselect.php',
+        'HTML_QuickForm_hierselect'
+      ),
+      'autocomplete' => array(
+        'HTML/QuickForm/autocomplete.php',
+        'HTML_QuickForm_autocomplete'
+      ),
+      'xbutton' => array(
+        'HTML/QuickForm/xbutton.php',
+        'HTML_QuickForm_xbutton'
+      ),
+      'advmultiselect' => array(
+        'HTML/QuickForm/advmultiselect.php',
+        'HTML_QuickForm_advmultiselect'
+      )
+    );
+  }
 }
 
 function CiviUnitTestCase_fatalErrorHandler($message) {
index f293afed7934ed7f804351180c8df9ae2c1c097e..52c6826fb1dfd9d54388939623eced64cc2ba545 100644 (file)
@@ -216,176 +216,4 @@ class api_v3_UFFieldTest extends CiviUnitTestCase {
       }
     }
   }
-
-  /**
-   * FIXME: something NULLs $GLOBALS['_HTML_QuickForm_registered_rules'] when the tests are ran all together
-   * (NB unclear if this is still required)
-   */
-  function _sethtmlGlobals() {
-    $GLOBALS['_HTML_QuickForm_registered_rules'] = array(
-      'required' => array(
-        'html_quickform_rule_required',
-        'HTML/QuickForm/Rule/Required.php'
-      ),
-      'maxlength' => array(
-        'html_quickform_rule_range',
-        'HTML/QuickForm/Rule/Range.php'
-      ),
-      'minlength' => array(
-        'html_quickform_rule_range',
-        'HTML/QuickForm/Rule/Range.php'
-      ),
-      'rangelength' => array(
-        'html_quickform_rule_range',
-        'HTML/QuickForm/Rule/Range.php'
-      ),
-      'email' => array(
-        'html_quickform_rule_email',
-        'HTML/QuickForm/Rule/Email.php'
-      ),
-      'regex' => array(
-        'html_quickform_rule_regex',
-        'HTML/QuickForm/Rule/Regex.php'
-      ),
-      'lettersonly' => array(
-        'html_quickform_rule_regex',
-        'HTML/QuickForm/Rule/Regex.php'
-      ),
-      'alphanumeric' => array(
-        'html_quickform_rule_regex',
-        'HTML/QuickForm/Rule/Regex.php'
-      ),
-      'numeric' => array(
-        'html_quickform_rule_regex',
-        'HTML/QuickForm/Rule/Regex.php'
-      ),
-      'nopunctuation' => array(
-        'html_quickform_rule_regex',
-        'HTML/QuickForm/Rule/Regex.php'
-      ),
-      'nonzero' => array(
-        'html_quickform_rule_regex',
-        'HTML/QuickForm/Rule/Regex.php'
-      ),
-      'callback' => array(
-        'html_quickform_rule_callback',
-        'HTML/QuickForm/Rule/Callback.php'
-      ),
-      'compare' => array(
-        'html_quickform_rule_compare',
-        'HTML/QuickForm/Rule/Compare.php'
-      )
-    );
-    // FIXME: …ditto for $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']
-    $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = array(
-      'group' => array(
-        'HTML/QuickForm/group.php',
-        'HTML_QuickForm_group'
-      ),
-      'hidden' => array(
-        'HTML/QuickForm/hidden.php',
-        'HTML_QuickForm_hidden'
-      ),
-      'reset' => array(
-        'HTML/QuickForm/reset.php',
-        'HTML_QuickForm_reset'
-      ),
-      'checkbox' => array(
-        'HTML/QuickForm/checkbox.php',
-        'HTML_QuickForm_checkbox'
-      ),
-      'file' => array(
-        'HTML/QuickForm/file.php',
-        'HTML_QuickForm_file'
-      ),
-      'image' => array(
-        'HTML/QuickForm/image.php',
-        'HTML_QuickForm_image'
-      ),
-      'password' => array(
-        'HTML/QuickForm/password.php',
-        'HTML_QuickForm_password'
-      ),
-      'radio' => array(
-        'HTML/QuickForm/radio.php',
-        'HTML_QuickForm_radio'
-      ),
-      'button' => array(
-        'HTML/QuickForm/button.php',
-        'HTML_QuickForm_button'
-      ),
-      'submit' => array(
-        'HTML/QuickForm/submit.php',
-        'HTML_QuickForm_submit'
-      ),
-      'select' => array(
-        'HTML/QuickForm/select.php',
-        'HTML_QuickForm_select'
-      ),
-      'hiddenselect' => array(
-        'HTML/QuickForm/hiddenselect.php',
-        'HTML_QuickForm_hiddenselect'
-      ),
-      'text' => array(
-        'HTML/QuickForm/text.php',
-        'HTML_QuickForm_text'
-      ),
-      'textarea' => array(
-        'HTML/QuickForm/textarea.php',
-        'HTML_QuickForm_textarea'
-      ),
-      'fckeditor' => array(
-        'HTML/QuickForm/fckeditor.php',
-        'HTML_QuickForm_FCKEditor'
-      ),
-      'tinymce' => array(
-        'HTML/QuickForm/tinymce.php',
-        'HTML_QuickForm_TinyMCE'
-      ),
-      'dojoeditor' => array(
-        'HTML/QuickForm/dojoeditor.php',
-        'HTML_QuickForm_dojoeditor'
-      ),
-      'link' => array(
-        'HTML/QuickForm/link.php',
-        'HTML_QuickForm_link'
-      ),
-      'advcheckbox' => array(
-        'HTML/QuickForm/advcheckbox.php',
-        'HTML_QuickForm_advcheckbox'
-      ),
-      'date' => array(
-        'HTML/QuickForm/date.php',
-        'HTML_QuickForm_date'
-      ),
-      'static' => array(
-        'HTML/QuickForm/static.php',
-        'HTML_QuickForm_static'
-      ),
-      'header' => array(
-        'HTML/QuickForm/header.php',
-        'HTML_QuickForm_header'
-      ),
-      'html' => array(
-        'HTML/QuickForm/html.php',
-        'HTML_QuickForm_html'
-      ),
-      'hierselect' => array(
-        'HTML/QuickForm/hierselect.php',
-        'HTML_QuickForm_hierselect'
-      ),
-      'autocomplete' => array(
-        'HTML/QuickForm/autocomplete.php',
-        'HTML_QuickForm_autocomplete'
-      ),
-      'xbutton' => array(
-        'HTML/QuickForm/xbutton.php',
-        'HTML_QuickForm_xbutton'
-      ),
-      'advmultiselect' => array(
-        'HTML/QuickForm/advmultiselect.php',
-        'HTML_QuickForm_advmultiselect'
-      )
-    );
-  }
 }