3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_OnlineMultiplePaymentProcessorTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testOnlineMultpiplePaymentProcessor() {
36 // Log in using webtestLogin() method
37 $this->webtestLogin();
39 $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7);
40 $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7);
41 $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7);
42 $pageId = $this->webtestAddContributionPage($hash = NULL,
44 $pageTitle = $donationPageTitle,
45 $processor = array($proProcessorName => 'Dummy', $standardProcessorName => 'PayPal_Standard'),
46 $amountSection = TRUE,
51 $membershipTypes = FALSE,
52 $memPriceSetId = NULL,
55 $profilePostId = NULL,
59 $isAddPaymentProcessor = TRUE,
60 $isPcpApprovalNeeded = FALSE,
61 $isSeparatePayment = FALSE,
62 $honoreeSection = FALSE,
63 $allowOtherAmmount = TRUE
66 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
67 $this->waitForTextPresent($donationPageTitle);
69 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
70 $lastName = 'An' . substr(sha1(rand()), 0, 7);
72 $this->type("email-5", $firstName . "@example.com");
74 $this->type("first_name", $firstName);
75 $this->type("last_name", $lastName);
77 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
79 $streetAddress = "100 Main Street";
80 $this->type("street_address-1", $streetAddress);
81 $this->type("city-1", "San Francisco");
82 $this->type("postal_code-1", "94117");
83 $this->select("country-1", "value=1228");
84 $this->select("state_province-1", "value=1001");
86 $this->assertTrue($this->isTextPresent("Payment Method"));
87 $xpath = "xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]";
90 $this->waitForElementPresent("credit_card_type");
93 $this->select("credit_card_type", "value=Visa");
94 $this->type("credit_card_number", "4111111111111111");
95 $this->type("cvv2", "000");
96 $this->select("credit_card_exp_date[M]", "value=1");
97 $this->select("credit_card_exp_date[Y]", "value=2020");
100 $this->type("billing_first_name", $firstName . "billing");
101 $this->type("billing_last_name", $lastName . "billing");
102 $this->type("billing_street_address-5", "15 Main St.");
103 $this->type(" billing_city-5", "San Jose");
104 $this->select("billing_country_id-5", "value=1228");
105 $this->select("billing_state_province_id-5", "value=1004");
106 $this->type("billing_postal_code-5", "94129");
107 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
109 $this->click("_qf_Confirm_next-bottom");
110 $this->waitForPageToLoad($this->getTimeoutMsec());
112 //login to check contribution
116 function testOnlineMultiplePaymentProcessorWithPayLater() {
118 // Log in using webtestLogin() method
119 $this->webtestLogin();
122 $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7);
123 $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7);
124 $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7);
125 $hash = substr(sha1(rand()), 0, 7);
126 $pageId = $this->webtestAddContributionPage($hash,
128 $pageTitle = $donationPageTitle,
129 $processor = array($proProcessorName => 'Dummy'),
130 $amountSection = TRUE,
135 $membershipTypes = FALSE,
136 $memPriceSetId = NULL,
139 $profilePostId = NULL,
143 $isAddPaymentProcessor = TRUE,
144 $isPcpApprovalNeeded = FALSE,
145 $isSeparatePayment = FALSE,
146 $honoreeSection = FALSE,
147 $allowOtherAmmount = TRUE
150 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
151 $this->waitForTextPresent($donationPageTitle);
153 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
154 $lastName = 'An' . substr(sha1(rand()), 0, 7);
156 $this->type("email-5", $firstName . "@example.com");
158 $this->type("first_name", $firstName);
159 $this->type("last_name", $lastName);
161 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
163 $streetAddress = "100 Main Street";
164 $this->type("street_address-1", $streetAddress);
165 $this->type("city-1", "San Francisco");
166 $this->type("postal_code-1", "94117");
167 $this->select("country-1", "value=1228");
168 $this->select("state_province-1", "value=1001");
170 $this->assertTrue($this->isTextPresent("Payment Method"));
171 $payLaterText = "Pay later label $hash";
172 $xpath = "xpath=//label[text() = '{$payLaterText}']/preceding-sibling::input[1]";
173 $this->click($xpath);
175 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
177 $payLaterInstructionsText = "Pay later instructions $hash";
178 $this->assertTrue($this->isTextPresent($payLaterInstructionsText));
180 $this->click("_qf_Confirm_next-bottom");
181 $this->waitForPageToLoad($this->getTimeoutMsec());
183 $this->assertTrue($this->isTextPresent($payLaterInstructionsText));
185 //login to check contribution
186 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
188 $this->type('sort_name', "$firstName $lastName");
189 $this->check('contribution_test');
190 $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
191 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom');
193 'From' => "{$firstName} {$lastName}",
194 'Financial Type' => 'Donation',
195 'Contribution Status' => 'Pending : Pay Later',
197 $this->webtestVerifyTabularData($expected);
198 $this->click('_qf_ContributionView_cancel-bottom');