Skip to content

Commit

Permalink
Merge pull request #10 from colemanw/tests
Browse files Browse the repository at this point in the history
Make webtest helper fn for enabling components
  • Loading branch information
colemanw committed Mar 2, 2013
2 parents fa1a0b4 + 1fbd57f commit e39f30e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
21 changes: 21 additions & 0 deletions tests/phpunit/CiviTest/CiviSeleniumTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
12 changes: 1 addition & 11 deletions tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit e39f30e

Please sign in to comment.