CRM-18438: Webtest
authorWeb Access <rohan.katkar@webaccessglobal.com>
Wed, 20 Apr 2016 09:56:58 +0000 (15:26 +0530)
committerWeb Access <rohan.katkar@webaccessglobal.com>
Wed, 20 Apr 2016 12:07:32 +0000 (17:37 +0530)
Minor changes

Warning fix

tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Contribute/OfflineContributionTest.php

index c3cd052b7f7b383a240212857cd07ea0866c41db..fa9b823b7b827a937748e932fb7803497dd94b8c 100644 (file)
@@ -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).
index 88d9a4dc2585a2b49dff8aff4d7744944bb10394..fb79858daa9ea047b9646c0f10d6eb58d21d18e4 100644 (file)
@@ -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");
+  }
+
 }