Commit | Line | Data |
---|---|---|
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 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { | |
30 | function testContributionPageAdd() { | |
31 | // open browser, login | |
6a488035 TO |
32 | $this->webtestLogin(); |
33 | ||
34 | // a random 7-char string and an even number to make this pass unique | |
35 | $hash = substr(sha1(rand()), 0, 7); | |
36 | $rand = 2 * rand(2, 50); | |
37 | $pageTitle = 'Donate Online ' . $hash; | |
38 | // create contribution page with randomized title and default params | |
39 | $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array("Webtest Dummy" . substr(sha1(rand()), 0, 7) => 'Dummy'), TRUE, TRUE, 'required'); | |
40 | ||
41 | $this->open($this->sboxPath . 'civicrm/admin/contribute?reset=1'); | |
42 | $this->waitForPageToLoad(); | |
43 | ||
44 | // search for the new contrib page and go to its test version | |
45 | $this->type('title', $pageTitle); | |
46 | $this->click('_qf_SearchContribution_refresh'); | |
47 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
48 | ||
49 | // select testdrive mode | |
50 | $this->isTextPresent($pageTitle); | |
51 | $this->open($this->sboxPath . 'civicrm/contribute/transact?reset=1&action=preview&id=' . $pageId); | |
52 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
53 | // verify whatever’s possible to verify | |
54 | // FIXME: ideally should be expanded | |
55 | $texts = array( | |
56 | "Title - New Membership $hash", | |
57 | "This is introductory message for $pageTitle", | |
58 | '$ 50.00 Student', | |
59 | "$ $rand.00 Label $hash", | |
60 | "Pay later label $hash", | |
61 | 'Organization Details', | |
62 | 'Other Amount', | |
63 | 'I pledge to contribute this amount every', | |
64 | "Honoree Section Title $hash", | |
65 | "Honoree Introductory Message $hash", | |
66 | 'In Honor of', | |
67 | 'Name and Address', | |
68 | 'Summary Overlay', | |
69 | ); | |
70 | foreach ($texts as $text) { | |
71 | $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); | |
72 | } | |
73 | } | |
74 | ||
75 | /* | |
76 | * check CRM-7943 | |
77 | */ | |
78 | function testContributionPageSeparatePayment() { | |
79 | // open browser, login | |
6a488035 TO |
80 | $this->webtestLogin(); |
81 | ||
82 | // a random 7-char string and an even number to make this pass unique | |
83 | $hash = substr(sha1(rand()), 0, 7); | |
84 | $rand = 2 * rand(2, 50); | |
85 | $pageTitle = 'Donate Online ' . $hash; | |
86 | ||
87 | // create contribution page with randomized title, default params and separate payment for Membership and Contribution | |
88 | $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array("Webtest Dummy" . substr(sha1(rand()), 0, 7) => 'Dummy'), | |
89 | TRUE, TRUE, 'required', TRUE, FALSE, TRUE, NULL, TRUE, | |
90 | 1, 7, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE | |
91 | ); | |
92 | ||
93 | $this->open($this->sboxPath . 'civicrm/admin/contribute?reset=1'); | |
94 | $this->waitForPageToLoad(); | |
95 | ||
96 | // search for the new contrib page and go to its test version | |
97 | $this->type('title', $pageTitle); | |
98 | $this->click('_qf_SearchContribution_refresh'); | |
99 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
100 | ||
101 | // select testdrive mode | |
102 | $this->isTextPresent($pageTitle); | |
103 | $this->open($this->sboxPath . 'civicrm/contribute/transact?reset=1&action=preview&id=' . $pageId); | |
104 | ||
105 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
106 | $texts = array( | |
107 | "Title - New Membership $hash", | |
108 | "This is introductory message for $pageTitle", | |
109 | "$ $rand.00 Label $hash", | |
110 | "Pay later label $hash", | |
111 | 'Organization Details', | |
112 | 'Other Amount', | |
113 | 'I pledge to contribute this amount every', | |
114 | "Honoree Section Title $hash", | |
115 | "Honoree Introductory Message $hash", | |
116 | 'In Honor of', | |
117 | 'Name and Address', | |
118 | 'Summary Overlay', | |
119 | ); | |
120 | foreach ($texts as $text) { | |
121 | $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); | |
122 | } | |
123 | } | |
124 | ||
125 | /* | |
126 | * check CRM-7949 | |
127 | */ | |
128 | function testContributionPageSeparatePaymentPayLater() { | |
129 | // open browser, login | |
6a488035 TO |
130 | $this->webtestLogin(); |
131 | ||
132 | // a random 7-char string and an even number to make this pass unique | |
133 | $hash = substr(sha1(rand()), 0, 7); | |
134 | $rand = 2 * rand(2, 50); | |
135 | $pageTitle = 'Donate Online ' . $hash; | |
136 | ||
137 | // create contribution page with randomized title, default params and separate payment for Membership and Contribution | |
138 | $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, NULL, | |
139 | TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, NULL, FALSE, | |
140 | 1, 0, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE | |
141 | ); | |
142 | ||
143 | $this->open($this->sboxPath . 'civicrm/admin/contribute?reset=1'); | |
144 | $this->waitForPageToLoad(); | |
145 | ||
146 | // search for the new contrib page and go to its test version | |
147 | $this->type('title', $pageTitle); | |
148 | $this->click('_qf_SearchContribution_refresh'); | |
149 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
150 | ||
151 | //get Url for Live Contribution Page | |
152 | $registerUrl = "civicrm/contribute/transact?reset=1&id=$pageId"; | |
153 | //logout | |
154 | $this->open($this->sboxPath . 'civicrm/logout?reset=1'); | |
155 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
156 | ||
157 | //Open Live Contribution Page | |
158 | $this->open($this->sboxPath . $registerUrl); | |
159 | $this->waitForElementPresent('_qf_Main_upload-bottom'); | |
160 | ||
161 | $firstName = 'Ya' . substr(sha1(rand()), 0, 4); | |
162 | $lastName = 'Cha' . substr(sha1(rand()), 0, 7); | |
163 | ||
164 | $this->type('email-5', $firstName . '@example.com'); | |
165 | $this->type('first_name', $firstName); | |
166 | $this->type('last_name', $lastName); | |
167 | //$this->click( "xpath=id('Main')/x:div[2]/x:div[3]/x:div[2]/x:label[2]" ); | |
168 | $this->waitForElementPresent('_qf_Main_upload-bottom'); | |
169 | $this->click('_qf_Main_upload-bottom'); | |
170 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
171 | $this->waitForElementPresent('_qf_Confirm_next-bottom'); | |
172 | ||
173 | $this->click('_qf_Confirm_next-bottom'); | |
174 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
175 | ||
176 | //login to check contribution | |
177 | $this->open($this->sboxPath); | |
178 | ||
179 | // Log in using webtestLogin() method | |
180 | $this->webtestLogin(); | |
181 | ||
182 | //Find Contribution | |
183 | $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); | |
184 | ||
185 | $this->waitForElementPresent('contribution_date_low'); | |
186 | ||
187 | $this->type('sort_name', "$firstName $lastName"); | |
b68dea89 | 188 | $this->select('financial_type_id',"label=Member Dues"); |
6a488035 TO |
189 | $this->click('_qf_Search_refresh'); |
190 | ||
191 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
192 | ||
b68dea89 | 193 | //View Contribution for membership fee |
6a488035 TO |
194 | $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); |
195 | $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); | |
196 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
197 | $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); | |
6a488035 | 198 | $expected = array( |
b68dea89 DG |
199 | 'From' => "{$firstName} {$lastName}", |
200 | 'Financial Type' => 'Member Dues', | |
201 | 'Total Amount' => '$ 50.00', | |
202 | 'Contribution Status' => 'Pending : Pay Later', | |
6a488035 | 203 | ); |
b68dea89 DG |
204 | $this->webtestVerifyTabularData($expected); |
205 | $this->click('_qf_ContributionView_cancel-bottom'); | |
206 | ||
207 | //View Contribution for separate contribution | |
208 | $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); | |
209 | // Open search criteria again | |
210 | $this->click("xpath=id('Search')/x:div[2]/x:div/x:div[1]"); | |
211 | $this->waitForElementPresent("financial_type_id"); | |
212 | $this->select('financial_type_id',"label=Donation"); | |
213 | $this->click('_qf_Search_refresh'); | |
214 | ||
215 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
216 | $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); | |
217 | ||
218 | $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); | |
219 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
220 | $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); | |
221 | $expected = array( | |
222 | 'From' => "{$firstName} {$lastName}", | |
223 | 'Financial Type' => 'Donation', | |
224 | 'Contribution Status' => 'Pending : Pay Later', | |
225 | ); | |
226 | $this->webtestVerifyTabularData($expected); | |
6a488035 TO |
227 | $this->click('_qf_ContributionView_cancel-bottom'); |
228 | ||
229 | ||
230 | //Find Member | |
231 | $this->open($this->sboxPath . 'civicrm/member/search?reset=1'); | |
232 | $this->waitForElementPresent('member_source'); | |
233 | $this->type('sort_name', "$firstName $lastName"); | |
234 | $this->click('_qf_Search_refresh'); | |
235 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
236 | ||
237 | //visit the Member View link | |
238 | $this->waitForElementPresent("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); | |
239 | $this->click("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']"); | |
240 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
241 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
242 | ||
243 | //View Membership Record | |
244 | $expected = array( | |
b68dea89 DG |
245 | 'Member' => "{$firstName} {$lastName}", |
246 | 'Membership Type' => 'Student', | |
247 | 'Status' => 'Pending', | |
6a488035 | 248 | ); |
b68dea89 | 249 | $this->webtestVerifyTabularData($expected); |
6a488035 TO |
250 | $this->click('_qf_MembershipView_cancel-bottom'); |
251 | } | |
252 | } | |
253 |