From feb02c31f51d8b7a0a88cf9d436160e9399e8828 Mon Sep 17 00:00:00 2001 From: Web Access Date: Wed, 24 Jun 2015 19:12:56 +0530 Subject: [PATCH] Webtest for contribution search by premiums --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 10 ++ .../Contribute/OnlineContributionTest.php | 118 ++++++++++++++++++ 2 files changed, 128 insertions(+) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 7d50b82acd..5c67e83c2d 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1355,6 +1355,16 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $text = "'Premium' information has been saved."; $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); + $this->openCiviPage("admin/contribute", "reset=1"); + $this->waitForAjaxContent(); + $this->click("xpath=//table['dataTables_wrapper no-footer']/tbody//tr/td[1]/strong[text()='$pageTitle']/../../td[4]/div[1]/span/ul/li[8]/a[text()='Premiums']"); + $this->waitForElementPresent('_qf_Premium_cancel-bottom'); + $this->click("xpath=//div[@class='messages status no-popup']/a[text()='add one']"); + $this->waitForElementPresent('_qf_AddProduct_cancel-bottom'); + $this->select('product_id', "value=1"); + $this->click('_qf_AddProduct_next-bottom'); + $this->waitForElementPresent('_qf_Premium_cancel-bottom'); + $this->click('_qf_Premium_next-bottom'); } if ($widget) { diff --git a/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php b/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php index dce0c93e9b..1682eaed03 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php @@ -378,4 +378,122 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { $this->webtestVerifyTabularData($expected); } + //CRM-16713: Contribution search by premiums on find contribution form. + public function testOnlineContributionWithPremium() { + $this->webtestLogin(); + + // Use default payment processor + $processorName = 'Test Processor'; + $processorType = 'Dummy'; + $pageTitle = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(10, 50); + $hash = substr(sha1(rand()), 0, 7); + $amountSection = TRUE; + $payLater = FALSE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = FALSE; + $friend = TRUE; + $profilePreId = 1; + $profilePostId = NULL; + $premiums = TRUE; + $widget = FALSE; + $pcp = FALSE; + $memPriceSetId = NULL; + + // create a new online contribution page + // create contribution page with randomized title and default params + $pageId = $this->webtestAddContributionPage($hash, + $rand, + $pageTitle, + array($processorName => $processorType), + $amountSection, + $payLater, + $onBehalf, + $pledges, + $recurring, + $memberships, + $memPriceSetId, + $friend, + $profilePreId, + $profilePostId, + $premiums, + $widget, + $pcp + ); + + //logout + $this->webtestLogout(); + + //Open Live Contribution Page + $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); + + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); + $lastName = 'An' . substr(sha1(rand()), 0, 7); + + $this->type("email-5", $firstName . "@example.com"); + + $this->waitForAjaxContent(); + $this->click("xpath=//div[@id='premiums-listings']/div[2]/div[1]"); + $this->waitForAjaxContent(); + $this->select("xpath=//div[@id='premiums']/fieldset/div[@id='premiums-listings']/div[2]/div[2]/div[2]/div[4]/p/select", "value=Black"); + + $this->type("first_name", $firstName); + $this->type("last_name", $lastName); + + $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input"); + $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100); + + $streetAddress = "100 Main Street"; + $this->type("street_address-1", $streetAddress); + $this->type("city-1", "San Francisco"); + $this->type("postal_code-1", "94117"); + $this->select("country-1", "value=1228"); + $this->select("state_province-1", "value=1001"); + + //Credit Card Info + $this->select("credit_card_type", "value=Visa"); + $this->type("credit_card_number", "4111111111111111"); + $this->type("cvv2", "000"); + $this->select("credit_card_exp_date[M]", "value=1"); + $this->select("credit_card_exp_date[Y]", "value=2020"); + + //Billing Info + $this->type("billing_first_name", $firstName . "billing"); + $this->type("billing_last_name", $lastName . "billing"); + $this->type("billing_street_address-5", "15 Main St."); + $this->type(" billing_city-5", "San Jose"); + $this->select("billing_country_id-5", "value=1228"); + $this->select("billing_state_province_id-5", "value=1004"); + $this->type("billing_postal_code-5", "94129"); + $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); + + $this->click("_qf_Confirm_next-bottom"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + + // Log in using webtestLogin() method + $this->webtestLogin(); + + //Find Contribution + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); + + $this->type("sort_name", "$lastName $firstName"); + $this->multiselect2('contribution_product_id', array('Coffee Mug')); + $this->click("_qf_Search_refresh"); + $this->waitForElementPresent("xpath=//div[@id='contributionSearch']/table/tbody//tr/td[11]/span/a[text()='View']"); + $this->click("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]/td[3]/a[text()='{$lastName}, {$firstName}']/../../td[11]/span/a[text()='View']"); + $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]"); + + //View Contribution Record and verify data + $expected = array( + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => 'Donation', + 'Total Amount' => '100.00', + 'Contribution Status' => 'Completed', + 'Premium' => 'Coffee Mug', + ); + $this->webtestVerifyTabularData($expected); + } + } -- 2.25.1