}
}
+ /**
+ * Ensures the required currencies are enabled.
+ * @param $currencies
+ */
+ public function enableCurrency($currencies) {
+ $this->openCiviPage("admin/setting/localization", "reset=1", "_qf_Localization_next-bottom");
+ $enabledCurrency = $this->getSelectOptions("currencyLimit-t");
+ foreach ($enabledCurrency as $k => $val) {
+ $enabledCurrency[$k] = substr($val, 0, 3);
+ }
+ $added = FALSE;
+ foreach ((array) $currencies as $curr) {
+ if (!in_array($curr, $enabledCurrency)) {
+ $this->addSelection("currencyLimit-f", "value=$curr");
+ $this->click("//option[@value='$curr']");
+ $this->click("add");
+ $added = TRUE;
+ }
+ }
+ if ($added) {
+ $this->clickLink("_qf_Localization_next-bottom");
+ }
+ }
+
/**
* 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).
$this->webtestVerifyTabularData($expected);
}
+ public function testDefaultCurrancy() {
+ $this->webtestLogin();
+ $this->enableCurrency(array('GBP', 'EUR'));
+
+ //Create a contact.
+ $firstName = 'John' . substr(sha1(rand()), 0, 7);
+ $lastName = 'Peterson' . substr(sha1(rand()), 0, 7);
+ $this->webtestAddContact($firstName, $lastName);
+
+ //Create contribution for contact
+ $this->waitForElementPresent("css=li#tab_contribute a");
+ $this->click("css=li#tab_contribute a");
+ $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
+ $this->click("link=Record Contribution (Check, Cash, EFT ...)");
+ $this->waitForElementPresent("financial_type_id");
+ $this->select("financial_type_id", "value=1");
+ $this->select("currency", "value=GBP");
+ $this->type("total_amount", "100");
+ $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Save']");
+ $this->waitForAjaxContent();
+ $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']");
+ $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody/tr//td/a", "£ 100.00");
+ $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr//td/a", "£ 100.00");
+ $this->waitForElementPresent("xpath=//table[@id='info']");
+ $this->assertElementContainsText("xpath=//table[@id='info']/tbody/tr[2]/td[1]", "£ 100.00");
+ }
+
}