Merge pull request #3113 from deepak-srivastava/CRM-14431
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / UpdateContributionTest.php
index b7397903122b31662b93cff1cf72659fb56ec0da..315c4d24d0d502ab7eb624b676c6e249fa131dcc 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -44,14 +44,15 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
 
    $this->type("sort_name", "$lastName, $firstName");
-   $this->clickLink("_qf_Search_refresh");
+   $this->click("_qf_Search_refresh");
 
-   $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]/td[11]/span/a@href"));
+   $this->waitForElementPresent("xpath=//div[@class='crm-content-block']//div[@id='contributionSearch']");
+   $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[1]@href"));
    if (!empty($contriIDOff)) {
      $contriIDOff = substr($contriIDOff[1], (strrpos($contriIDOff[1], '=') + 1));
    }
 
-   $this->clickLink("xpath=//tr[@id='rowid{$contriIDOff}']/td[11]/span/a[2]", "total_amount");
+   $this->clickLink("xpath=//tr[@id='rowid{$contriIDOff}']/td[11]/span/a[2]", "total_amount", FALSE);
    $this->type("total_amount", "90");
    $this->clickLink('_qf_Contribution_upload');
 
@@ -89,7 +90,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $amount = 100.00;
    //Offline Pay Later Contribution
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
    $contId = $this->urlArg('id');
    $this->select("contribution_status_id", "label=Completed");
    $this->clickLink("_qf_Contribution_upload");
@@ -121,12 +123,11 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
      'is_deductible' => 1,
    );
    $this->addeditFinancialType($financialType);
-   $this->select("account_relationship", "label=Cost of Sales Account is");
-   $this->select("financial_account_id", "label=$from");
-   $this->clickLink("_qf_FinancialTypeAccount_next_new-botttom");
+   $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']");
    $this->select("account_relationship", "label=Premiums Inventory Account is");
    $this->select("financial_account_id", "label=$to");
    $this->clickLink("_qf_FinancialTypeAccount_next-botttom");
+   
    $premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
    $amount = 500;
    $sku = 'SKU';
@@ -162,9 +163,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
    // verify if Membership is created
-   $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
+   $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
    //click through to the Contribution edit screen
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom");
+   $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom");
    $contId = $this->urlArg('id');
    $this->waitForElementPresent("product_name_0");
    $this->select('product_name_0', "label=$premiumName2 ( $sku2 )");
@@ -187,18 +188,17 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $from = 'Premiums';
    $to = 'Premiums inventory';
    $financialType = array(
-     'name' => 'Test Financial'.substr(sha1(rand()), 0, 7),
+     'name' => 'Test Financial' . substr(sha1(rand()), 0, 7),
      'is_reserved' => 1,
      'is_deductible' => 1,
    );
    $this->addeditFinancialType($financialType);
-   $this->select("account_relationship", "label=Cost of Sales Account is");
-   $this->select("financial_account_id", "label=$from");
-   $this->clickLink("_qf_FinancialTypeAccount_next_new-botttom");
+   $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']");
+   
    $this->select("account_relationship", "label=Premiums Inventory Account is");
    $this->select("financial_account_id", "label=$to");
-   $this->click("_qf_FinancialTypeAccount_next-botttom");
-   $premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
+   $this->clickLink("_qf_FinancialTypeAccount_next-botttom");
+   $premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
    $amount = 500;
    $sku = 'SKU';
    $price = 300;
@@ -225,9 +225,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
    // verify if Membership is created
-   $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
+   $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
    //click through to the Contribution edit screen
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom");
+   $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom");
    $contId = $this->urlArg('id');
    $this->waitForElementPresent("product_name_0");
    $this->select('product_name_0', "value=0");
@@ -251,7 +251,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $from = array_search('Deposit Bank Account', $financialAccount);
    $this->addPaymentInstrument($label, $to);
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
    $contId = $this->urlArg('id');
    //change payment processor to newly created value
    $this->select("payment_instrument_id", "label=$label");
@@ -269,7 +270,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $label = 'TEST'.substr(sha1(rand()), 0, 7);
    $amount = 100.00;
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
    //Contribution status
    $this->select("contribution_status_id", "label=Refunded");
    $contId = $this->urlArg('id');
@@ -295,7 +297,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $label = 'TEST'.substr(sha1(rand()), 0, 7);
    $amount = 100.00;
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
    //Contribution status
    $this->select("contribution_status_id", "label=Cancelled");
    $contId = $this->urlArg('id');
@@ -327,7 +330,8 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $label = 'TEST'.substr(sha1(rand()), 0, 7);
    $amount = 100.00;
    $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
+   $this->clickLink("xpath=//div[@id='contributionSearch']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
    //Contribution status
    $this->select("financial_type_id", "value=3");
    $contId = $this->urlArg('id');
@@ -448,11 +452,11 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
 
+   $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
    // verify if Membership is created
-   $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
 
    //click through to the Membership view screen
-   $this->clickLink("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom");
+   $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
 
    $expected = array(
      'Financial Type' => 'Donation',
@@ -460,11 +464,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
      'Contribution Status' => $status,
    );
    $this->webtestVerifyTabularData($expected);
-   $this->clickLink("_qf_ContributionView_cancel-top");
-   // Because it tends to cause problems, all uses of sleep() must be justified in comments
-   // Sleep should never be used for wait for anything to load from the server
-   // Justification for this instance: FIXME
-   sleep(4);
+   $this->click("_qf_ContributionView_cancel-bottom");
  }
 }