Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 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 | ||
00be9182 | 37 | public 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 | ||
4ea7e2aa | 80 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div/input", 100); |
6a488035 TO |
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"); | |
4ea7e2aa | 87 | $this->waitForElementPresent("state_province-1"); |
6a488035 TO |
88 | $this->select("state_province-1", "value=1001"); |
89 | ||
90 | $this->assertTrue($this->isTextPresent("Payment Method")); | |
d48ea865 WA |
91 | $this->waitForElementPresent("xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]"); |
92 | $this->click("xpath=//label[text() = '{$proProcessorName}']/preceding-sibling::input[1]"); | |
6a488035 TO |
93 | |
94 | $this->waitForElementPresent("credit_card_type"); | |
95 | ||
96 | //Credit Card Info | |
97 | $this->select("credit_card_type", "value=Visa"); | |
98 | $this->type("credit_card_number", "4111111111111111"); | |
99 | $this->type("cvv2", "000"); | |
100 | $this->select("credit_card_exp_date[M]", "value=1"); | |
101 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
102 | ||
103 | //Billing Info | |
104 | $this->type("billing_first_name", $firstName . "billing"); | |
105 | $this->type("billing_last_name", $lastName . "billing"); | |
106 | $this->type("billing_street_address-5", "15 Main St."); | |
107 | $this->type(" billing_city-5", "San Jose"); | |
108 | $this->select("billing_country_id-5", "value=1228"); | |
109 | $this->select("billing_state_province_id-5", "value=1004"); | |
110 | $this->type("billing_postal_code-5", "94129"); | |
225a8648 | 111 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
6a488035 TO |
112 | |
113 | $this->click("_qf_Confirm_next-bottom"); | |
114 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
76e86fd8 | 115 | |
6a488035 | 116 | //login to check contribution |
76e86fd8 | 117 | |
6a488035 TO |
118 | } |
119 | ||
00be9182 | 120 | public function testOnlineMultiplePaymentProcessorWithPayLater() { |
6a488035 TO |
121 | |
122 | // Log in using webtestLogin() method | |
123 | $this->webtestLogin(); | |
124 | ||
6a488035 TO |
125 | $proProcessorName = "Pro " . substr(sha1(rand()), 0, 7); |
126 | $standardProcessorName = "Standard " . substr(sha1(rand()), 0, 7); | |
127 | $donationPageTitle = "Donation" . substr(sha1(rand()), 0, 7); | |
128 | $hash = substr(sha1(rand()), 0, 7); | |
129 | $pageId = $this->webtestAddContributionPage($hash, | |
130 | $rand = NULL, | |
131 | $pageTitle = $donationPageTitle, | |
132 | $processor = array($proProcessorName => 'Dummy'), | |
133 | $amountSection = TRUE, | |
134 | $payLater = TRUE, | |
135 | $onBehalf = FALSE, | |
136 | $pledges = TRUE, | |
137 | $recurring = FALSE, | |
138 | $membershipTypes = FALSE, | |
139 | $memPriceSetId = NULL, | |
140 | $friend = FALSE, | |
141 | $profilePreId = 1, | |
142 | $profilePostId = NULL, | |
143 | $premiums = FALSE, | |
144 | $widget = FALSE, | |
145 | $pcp = FALSE, | |
146 | $isAddPaymentProcessor = TRUE, | |
147 | $isPcpApprovalNeeded = FALSE, | |
148 | $isSeparatePayment = FALSE, | |
149 | $honoreeSection = FALSE, | |
10525e44 | 150 | $allowOtherAmount = TRUE |
6a488035 TO |
151 | ); |
152 | ||
b45c587e CW |
153 | $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", NULL); |
154 | $this->waitForTextPresent($donationPageTitle); | |
6a488035 TO |
155 | |
156 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
157 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
76e86fd8 | 158 | |
6a488035 TO |
159 | $this->type("email-5", $firstName . "@example.com"); |
160 | ||
161 | $this->type("first_name", $firstName); | |
162 | $this->type("last_name", $lastName); | |
163 | ||
4ea7e2aa | 164 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div/input", 100); |
6a488035 TO |
165 | |
166 | $streetAddress = "100 Main Street"; | |
167 | $this->type("street_address-1", $streetAddress); | |
168 | $this->type("city-1", "San Francisco"); | |
169 | $this->type("postal_code-1", "94117"); | |
170 | $this->select("country-1", "value=1228"); | |
4ea7e2aa | 171 | $this->waitForElementPresent("state_province-1"); |
6a488035 TO |
172 | $this->select("state_province-1", "value=1001"); |
173 | ||
174 | $this->assertTrue($this->isTextPresent("Payment Method")); | |
175 | $payLaterText = "Pay later label $hash"; | |
176 | $xpath = "xpath=//label[text() = '{$payLaterText}']/preceding-sibling::input[1]"; | |
177 | $this->click($xpath); | |
178 | ||
5009a032 | 179 | $this->waitForAjaxContent(); |
5548f5f9 | 180 | $this->click("_qf_Main_upload-bottom"); |
181 | $this->waitForElementPresent("xpath=//div[@class='bold pay_later_receipt-section']"); | |
76e86fd8 | 182 | |
6a488035 | 183 | $payLaterInstructionsText = "Pay later instructions $hash"; |
d48ea865 | 184 | $this->assertElementContainsText("xpath=//div[@class='bold pay_later_receipt-section']/p", $payLaterInstructionsText); |
6a488035 | 185 | $this->click("_qf_Confirm_next-bottom"); |
6a488035 | 186 | |
5548f5f9 | 187 | $this->waitForElementPresent("xpath=//div[@class='help']/div/p"); |
d48ea865 | 188 | $this->assertElementContainsText("xpath=//div[@class='help']/div/p", $payLaterInstructionsText); |
6a488035 TO |
189 | |
190 | //login to check contribution | |
42daf119 | 191 | $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); |
deeea38d | 192 | $this->waitForAjaxContent(); |
42e55bb5 | 193 | $this->type('sort_name', "$lastName $firstName"); |
6a488035 | 194 | $this->check('contribution_test'); |
42e55bb5 | 195 | $this->click('_qf_Search_refresh'); |
deeea38d WA |
196 | $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']"); |
197 | $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']"); | |
42e55bb5 | 198 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
6a488035 | 199 | $expected = array( |
92915c55 TO |
200 | 'From' => "{$firstName} {$lastName}", |
201 | 'Financial Type' => 'Donation', | |
6a488035 TO |
202 | 'Contribution Status' => 'Pending : Pay Later', |
203 | ); | |
204 | $this->webtestVerifyTabularData($expected); | |
205 | $this->click('_qf_ContributionView_cancel-bottom'); | |
206 | } | |
96025800 | 207 | |
6a488035 | 208 | } |