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