Start migrating to use clickLink method
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / OnlineMultiplePaymentProcessorTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
25 */
26
27
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSeleniumTestCase {
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testOnlineMultpiplePaymentProcessor() {
35
36 // Log in using webtestLogin() method
37 $this->webtestLogin();
38
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,
43 $rand = NULL,
44 $pageTitle = $donationPageTitle,
45 $processor = array($proProcessorName => 'Dummy', $standardProcessorName => 'PayPal_Standard'),
46 $amountSection = TRUE,
47 $payLater = TRUE,
48 $onBehalf = FALSE,
49 $pledges = TRUE,
50 $recurring = FALSE,
51 $membershipTypes = FALSE,
52 $memPriceSetId = NULL,
53 $friend = FALSE,
54 $profilePreId = 1,
55 $profilePostId = NULL,
56 $premiums = FALSE,
57 $widget = FALSE,
58 $pcp = FALSE,
59 $isAddPaymentProcessor = TRUE,
60 $isPcpApprovalNeeded = FALSE,
61 $isSeparatePayment = FALSE,
62 $honoreeSection = FALSE,
63 $allowOtherAmmount = TRUE
64 );
65
66 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
67 $this->waitForTextPresent($donationPageTitle);
68
69 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
70 $lastName = 'An' . substr(sha1(rand()), 0, 7);
71
72 $this->type("email-5", $firstName . "@example.com");
73
74 $this->type("first_name", $firstName);
75 $this->type("last_name", $lastName);
76
77 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
78
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");
85
86 $this->assertTrue($this->isTextPresent("Payment Method"));
87 $xpath = "xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]";
88 $this->click($xpath);
89
90 $this->waitForElementPresent("credit_card_type");
91
92 //Credit Card Info
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");
98
99 //Billing Info
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");
108
109 $this->click("_qf_Confirm_next-bottom");
110 $this->waitForPageToLoad($this->getTimeoutMsec());
111
112 //login to check contribution
113
114 }
115
116 function testOnlineMultiplePaymentProcessorWithPayLater() {
117
118 // Log in using webtestLogin() method
119 $this->webtestLogin();
120
121
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,
127 $rand = NULL,
128 $pageTitle = $donationPageTitle,
129 $processor = array($proProcessorName => 'Dummy'),
130 $amountSection = TRUE,
131 $payLater = TRUE,
132 $onBehalf = FALSE,
133 $pledges = TRUE,
134 $recurring = FALSE,
135 $membershipTypes = FALSE,
136 $memPriceSetId = NULL,
137 $friend = FALSE,
138 $profilePreId = 1,
139 $profilePostId = NULL,
140 $premiums = FALSE,
141 $widget = FALSE,
142 $pcp = FALSE,
143 $isAddPaymentProcessor = TRUE,
144 $isPcpApprovalNeeded = FALSE,
145 $isSeparatePayment = FALSE,
146 $honoreeSection = FALSE,
147 $allowOtherAmmount = TRUE
148 );
149
150 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL);
151 $this->waitForTextPresent($donationPageTitle);
152
153 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
154 $lastName = 'An' . substr(sha1(rand()), 0, 7);
155
156 $this->type("email-5", $firstName . "@example.com");
157
158 $this->type("first_name", $firstName);
159 $this->type("last_name", $lastName);
160
161 $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100);
162
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");
169
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);
174
175 $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom");
176
177 $payLaterInstructionsText = "Pay later instructions $hash";
178 $this->assertTrue($this->isTextPresent($payLaterInstructionsText));
179
180 $this->click("_qf_Confirm_next-bottom");
181 $this->waitForPageToLoad($this->getTimeoutMsec());
182
183 $this->assertTrue($this->isTextPresent($payLaterInstructionsText));
184
185 //login to check contribution
186 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
187
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');
192 $expected = array(
193 'From' => "{$firstName} {$lastName}",
194 'Financial Type' => 'Donation',
195 'Contribution Status' => 'Pending : Pay Later',
196 );
197 $this->webtestVerifyTabularData($expected);
198 $this->click('_qf_ContributionView_cancel-bottom');
199 }
200 }
201