From 649c6141fb77c957d69cda01f29c3e2809700af0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 1 Mar 2013 17:23:37 -0800 Subject: [PATCH 1/2] Make helper fn for enabling components --- .../WebTest/Campaign/SurveyUsageScenarioTest.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php index 8f6e795a78cb..dbfc5fd4c72c 100644 --- a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php +++ b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php @@ -66,17 +66,7 @@ function testSurveyUsageScenario() { $this->click("_qf_GroupContact_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Enable CiviCampaign module if necessary - $this->openCiviPage("admin/setting/component", "reset=1", "_qf_Component_next-bottom"); - $enabledComponents = $this->getSelectOptions("enableComponents-t"); - if (!in_array("CiviCampaign", $enabledComponents)) { - $this->addSelection("enableComponents-f", "label=CiviCampaign"); - $this->click("//option[@value='CiviCampaign']"); - $this->click("add"); - $this->click("_qf_Component_next-bottom"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->assertElementContainsText("crm-notification-container", "Saved"); - } + $this->enableComponents(array('CiviCampaign')); // add the required Drupal permission $permissions = array('edit-2-administer-civicampaign'); From 1fbd57f8101fdaa452fc71c7e54c41e8ff9df90a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 1 Mar 2013 17:27:42 -0800 Subject: [PATCH 2/2] Needed to add this file too --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index e2235fd1c557..09026939aff2 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -214,6 +214,27 @@ function webtestGetConfig($field) { return $_config_backend[$field]; } + /** + * Ensures the required CiviCRM components are enabled + */ + function enableComponents($components) { + $this->openCiviPage("admin/setting/component", "reset=1", "_qf_Component_next-bottom"); + $enabledComponents = $this->getSelectOptions("enableComponents-t"); + $added = FALSE; + foreach ((array) $components as $comp) { + if (!in_array($comp, $enabledComponents)) { + $this->click("//option[@value='$comp']"); + $this->click("add"); + $added = TRUE; + } + } + if ($added) { + $this->click("_qf_Component_next-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->assertElementContainsText("crm-notification-container", "Saved"); + } + } + /** * Add a contact with the given first and last names and either a given email * (when specified), a random email (when true) or no email (when unspecified or null).