Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contribute_OnlineMultiplePaymentProcessorTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSeleniumTestCase { |
33 | protected function setUp() { | |
34 | parent::setUp(); | |
35 | } | |
36 | ||
37 | function testOnlineMultpiplePaymentProcessor() { | |
6a488035 TO |
38 | |
39 | // Log in using webtestLogin() method | |
40 | $this->webtestLogin(); | |
41 | ||
42 | $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7); | |
43 | $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7); | |
44 | $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7); | |
45 | $pageId = $this->webtestAddContributionPage($hash = NULL, | |
46 | $rand = NULL, | |
47 | $pageTitle = $donationPageTitle, | |
48 | $processor = array($proProcessorName => 'Dummy', $standardProcessorName => 'PayPal_Standard'), | |
49 | $amountSection = TRUE, | |
50 | $payLater = TRUE, | |
51 | $onBehalf = FALSE, | |
52 | $pledges = TRUE, | |
53 | $recurring = FALSE, | |
54 | $membershipTypes = FALSE, | |
55 | $memPriceSetId = NULL, | |
56 | $friend = FALSE, | |
57 | $profilePreId = 1, | |
58 | $profilePostId = NULL, | |
59 | $premiums = FALSE, | |
60 | $widget = FALSE, | |
61 | $pcp = FALSE, | |
62 | $isAddPaymentProcessor = TRUE, | |
63 | $isPcpApprovalNeeded = FALSE, | |
64 | $isSeparatePayment = FALSE, | |
65 | $honoreeSection = FALSE, | |
66 | $allowOtherAmmount = TRUE | |
67 | ); | |
68 | ||
b45c587e CW |
69 | $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL); |
70 | $this->waitForTextPresent($donationPageTitle); | |
6a488035 TO |
71 | |
72 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
73 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
74 | ||
75 | $this->type("email-5", $firstName . "@example.com"); | |
76 | ||
77 | $this->type("first_name", $firstName); | |
78 | $this->type("last_name", $lastName); | |
79 | ||
80 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100); | |
81 | ||
82 | $streetAddress = "100 Main Street"; | |
83 | $this->type("street_address-1", $streetAddress); | |
84 | $this->type("city-1", "San Francisco"); | |
85 | $this->type("postal_code-1", "94117"); | |
86 | $this->select("country-1", "value=1228"); | |
87 | $this->select("state_province-1", "value=1001"); | |
88 | ||
89 | $this->assertTrue($this->isTextPresent("Payment Method")); | |
90 | $xpath = "xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]"; | |
91 | $this->click($xpath); | |
92 | ||
93 | $this->waitForElementPresent("credit_card_type"); | |
94 | ||
95 | //Credit Card Info | |
96 | $this->select("credit_card_type", "value=Visa"); | |
97 | $this->type("credit_card_number", "4111111111111111"); | |
98 | $this->type("cvv2", "000"); | |
99 | $this->select("credit_card_exp_date[M]", "value=1"); | |
100 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
101 | ||
102 | //Billing Info | |
103 | $this->type("billing_first_name", $firstName . "billing"); | |
104 | $this->type("billing_last_name", $lastName . "billing"); | |
105 | $this->type("billing_street_address-5", "15 Main St."); | |
106 | $this->type(" billing_city-5", "San Jose"); | |
107 | $this->select("billing_country_id-5", "value=1228"); | |
108 | $this->select("billing_state_province_id-5", "value=1004"); | |
109 | $this->type("billing_postal_code-5", "94129"); | |
225a8648 | 110 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
111 | |
112 | $this->click("_qf_Confirm_next-bottom"); | |
113 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
76e86fd8 | 114 | |
6a488035 | 115 | //login to check contribution |
76e86fd8 | 116 | |
6a488035 TO |
117 | } |
118 | ||
119 | function testOnlineMultiplePaymentProcessorWithPayLater() { | |
6a488035 TO |
120 | |
121 | // Log in using webtestLogin() method | |
122 | $this->webtestLogin(); | |
123 | ||
6a488035 TO |
124 | $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7); |
125 | $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7); | |
126 | $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7); | |
127 | $hash = substr(sha1(rand()), 0, 7); | |
128 | $pageId = $this->webtestAddContributionPage($hash, | |
129 | $rand = NULL, | |
130 | $pageTitle = $donationPageTitle, | |
131 | $processor = array($proProcessorName => 'Dummy'), | |
132 | $amountSection = TRUE, | |
133 | $payLater = TRUE, | |
134 | $onBehalf = FALSE, | |
135 | $pledges = TRUE, | |
136 | $recurring = FALSE, | |
137 | $membershipTypes = FALSE, | |
138 | $memPriceSetId = NULL, | |
139 | $friend = FALSE, | |
140 | $profilePreId = 1, | |
141 | $profilePostId = NULL, | |
142 | $premiums = FALSE, | |
143 | $widget = FALSE, | |
144 | $pcp = FALSE, | |
145 | $isAddPaymentProcessor = TRUE, | |
146 | $isPcpApprovalNeeded = FALSE, | |
147 | $isSeparatePayment = FALSE, | |
148 | $honoreeSection = FALSE, | |
149 | $allowOtherAmmount = TRUE | |
150 | ); | |
151 | ||
b45c587e CW |
152 | $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL); |
153 | $this->waitForTextPresent($donationPageTitle); | |
6a488035 TO |
154 | |
155 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
156 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
76e86fd8 | 157 | |
6a488035 TO |
158 | $this->type("email-5", $firstName . "@example.com"); |
159 | ||
160 | $this->type("first_name", $firstName); | |
161 | $this->type("last_name", $lastName); | |
162 | ||
163 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 100); | |
164 | ||
165 | $streetAddress = "100 Main Street"; | |
166 | $this->type("street_address-1", $streetAddress); | |
167 | $this->type("city-1", "San Francisco"); | |
168 | $this->type("postal_code-1", "94117"); | |
169 | $this->select("country-1", "value=1228"); | |
170 | $this->select("state_province-1", "value=1001"); | |
171 | ||
172 | $this->assertTrue($this->isTextPresent("Payment Method")); | |
173 | $payLaterText = "Pay later label $hash"; | |
174 | $xpath = "xpath=//label[text() = '{$payLaterText}']/preceding-sibling::input[1]"; | |
175 | $this->click($xpath); | |
176 | ||
225a8648 | 177 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
76e86fd8 | 178 | |
6a488035 TO |
179 | $payLaterInstructionsText = "Pay later instructions $hash"; |
180 | $this->assertTrue($this->isTextPresent($payLaterInstructionsText)); | |
181 | ||
182 | $this->click("_qf_Confirm_next-bottom"); | |
183 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
184 | ||
185 | $this->assertTrue($this->isTextPresent($payLaterInstructionsText)); | |
186 | ||
187 | //login to check contribution | |
42daf119 | 188 | $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); |
6a488035 TO |
189 | |
190 | $this->type('sort_name', "$firstName $lastName"); | |
191 | $this->check('contribution_test'); | |
225a8648 CW |
192 | $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
193 | $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom'); | |
6a488035 TO |
194 | $expected = array( |
195 | 'From' => "{$firstName} {$lastName}", | |
196 | 'Financial Type' => 'Donation', | |
197 | 'Contribution Status' => 'Pending : Pay Later', | |
198 | ); | |
199 | $this->webtestVerifyTabularData($expected); | |
200 | $this->click('_qf_ContributionView_cancel-bottom'); | |
201 | } | |
202 | } | |
203 |