6 class CRM_Core_FormTest
extends CiviUnitTestCase
{
9 * Simulate opening various forms. All we're looking to do here is
10 * see if any warnings or notices come up, the equivalent of red boxes
11 * on the screen, but which are hidden when using popup forms.
12 * So no assertions required.
16 * @dataProvider formList
18 public function testOpeningForms(string $url) {
19 $this->createLoggedInUser();
21 $_SERVER['REQUEST_URI'] = $url;
22 $urlParts = explode('?', $url);
23 $_GET['q'] = $urlParts[0];
26 parse_str($urlParts[1], $parsed);
27 foreach ($parsed as $param => $value) {
28 $_REQUEST[$param] = $value;
31 $item = CRM_Core_Invoke
::getItem([$_GET['q']]);
33 CRM_Core_Invoke
::runItem($item);
36 foreach ($parsed as $param => $dontcare) {
37 unset($_REQUEST[$param]);
42 * Dataprovider for testOpeningForms().
43 * TODO: Add more forms!
47 public function formList(): array {
49 // Array key is descriptive term to make it clearer which form it is when it fails.
51 'civicrm/tag/edit?action=add&parent_id=',
53 'Assign Account to Financial Type' => [
54 'civicrm/admin/financial/financialType/accounts?action=add&reset=1&aid=1',
57 'civicrm/contact/search?reset=1',
59 'Fulltext search' => [
60 'civicrm/contact/search/custom?csid=15&reset=1',
65 public function testNewPriceField() {
66 $this->createLoggedInUser();
68 $priceSetId = $this->callAPISuccess('PriceSet', 'create', [
70 // extends contribution
72 'is_quick_config' => 0,
74 'financial_type_id' => 1,
76 'title' => 'Priciest Price Set',
79 $_SERVER['REQUEST_URI'] = "civicrm/admin/price/field?reset=1&action=add&sid={$priceSetId}";
80 $_GET['q'] = 'civicrm/admin/price/field';
81 $_REQUEST['reset'] = 1;
82 $_REQUEST['action'] = 'add';
83 $_REQUEST['sid'] = $priceSetId;
85 $item = CRM_Core_Invoke
::getItem([$_GET['q']]);
87 CRM_Core_Invoke
::runItem($item);
90 unset($_REQUEST['reset']);
91 unset($_REQUEST['action']);
92 unset($_REQUEST['sid']);
94 $this->callAPISuccess('PriceSet', 'delete', ['id' => $priceSetId]);