From b25b6f707580f2ca1f55986b25208a67db14111c Mon Sep 17 00:00:00 2001 From: Web Access Date: Wed, 20 Apr 2016 15:26:58 +0530 Subject: [PATCH] CRM-18438: Webtest Minor changes Warning fix --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 24 +++++++++++++++++ .../Contribute/OfflineContributionTest.php | 27 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index c3cd052b7f..fa9b823b7b 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -424,6 +424,30 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } } + /** + * 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). diff --git a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php index 88d9a4dc25..fb79858daa 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php @@ -438,4 +438,31 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { $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"); + } + } -- 2.25.1