3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_ContributionPageAddTest
extends CiviSeleniumTestCase
{
30 function testContributionPageAdd() {
31 // open browser, login
32 $this->webtestLogin();
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');
41 $this->openCiviPage("admin/contribute", "reset=1");
43 // search for the new contrib page and go to its test version
44 $this->type('title', $pageTitle);
45 $this->click('_qf_SearchContribution_refresh');
46 $this->waitForPageToLoad($this->getTimeoutMsec());
48 // select testdrive mode
49 $this->isTextPresent($pageTitle);
50 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom');
52 // verify whatever’s possible to verify
53 // FIXME: ideally should be expanded
55 "Title - New Membership $hash",
56 "This is introductory message for $pageTitle",
58 "$ $rand.00 Label $hash",
59 "Pay later label $hash",
60 'Organization Details',
62 'I pledge to contribute this amount every',
63 "Honoree Section Title $hash",
64 "Honoree Introductory Message $hash",
69 foreach ($texts as $text) {
70 $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
77 function testContributionPageSeparatePayment() {
78 // open browser, login
79 $this->webtestLogin();
81 // a random 7-char string and an even number to make this pass unique
82 $hash = substr(sha1(rand()), 0, 7);
83 $rand = 2 * rand(2, 50);
84 $pageTitle = 'Donate Online ' . $hash;
86 // create contribution page with randomized title, default params and separate payment for Membership and Contribution
87 $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array("Webtest Dummy" . substr(sha1(rand()), 0, 7) => 'Dummy'),
88 TRUE, TRUE, 'required', TRUE, FALSE, TRUE, NULL, TRUE,
89 1, 7, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE
92 $this->openCiviPage("admin/contribute", "reset=1");
94 // search for the new contrib page and go to its test version
95 $this->type('title', $pageTitle);
96 $this->click('_qf_SearchContribution_refresh');
97 $this->waitForPageToLoad($this->getTimeoutMsec());
99 // select testdrive mode
100 $this->isTextPresent($pageTitle);
101 $this->openCiviPage("contribute/transact", "reset=1&action=preview&id=$pageId", '_qf_Main_upload-bottom');
104 "Title - New Membership $hash",
105 "This is introductory message for $pageTitle",
106 "$ $rand.00 Label $hash",
107 "Pay later label $hash",
108 'Organization Details',
110 'I pledge to contribute this amount every',
111 "Honoree Section Title $hash",
112 "Honoree Introductory Message $hash",
117 foreach ($texts as $text) {
118 $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
125 function testContributionPageSeparatePaymentPayLater() {
126 // open browser, login
127 $this->webtestLogin();
129 // a random 7-char string and an even number to make this pass unique
130 $hash = substr(sha1(rand()), 0, 7);
131 $rand = 2 * rand(2, 50);
132 $pageTitle = 'Donate Online ' . $hash;
134 // create contribution page with randomized title, default params and separate payment for Membership and Contribution
135 $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, NULL,
136 TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, NULL, FALSE,
137 1, 0, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE
140 $this->openCiviPage("admin/contribute", "reset=1");
142 // search for the new contrib page and go to its test version
143 $this->type('title', $pageTitle);
144 $this->click('_qf_SearchContribution_refresh');
145 $this->waitForPageToLoad($this->getTimeoutMsec());
148 $this->webtestLogout();
150 //Open Live Contribution Page
151 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", '_qf_Main_upload-bottom');
153 $firstName = 'Ya' . substr(sha1(rand()), 0, 4);
154 $lastName = 'Cha' . substr(sha1(rand()), 0, 7);
156 $this->type('email-5', $firstName . '@example.com');
157 $this->type('first_name', $firstName);
158 $this->type('last_name', $lastName);
160 $this->click('_qf_Main_upload-bottom');
161 $this->waitForPageToLoad($this->getTimeoutMsec());
162 $this->waitForElementPresent('_qf_Confirm_next-bottom');
164 $this->click('_qf_Confirm_next-bottom');
165 $this->waitForPageToLoad($this->getTimeoutMsec());
167 //login to check contribution
168 $this->webtestLogin();
171 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
173 $this->type('sort_name', "$firstName $lastName");
174 $this->select('financial_type_id',"label=Member Dues");
175 $this->click('_qf_Search_refresh');
177 $this->waitForPageToLoad($this->getTimeoutMsec());
179 //View Contribution for membership fee
180 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
181 $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
182 $this->waitForPageToLoad($this->getTimeoutMsec());
183 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
185 'From' => "{$firstName} {$lastName}",
186 'Financial Type' => 'Member Dues',
187 'Total Amount' => '$ 50.00',
188 'Contribution Status' => 'Pending : Pay Later',
190 $this->webtestVerifyTabularData($expected);
191 $this->click('_qf_ContributionView_cancel-bottom');
193 //View Contribution for separate contribution
194 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
195 // Open search criteria again
196 $this->click("xpath=id('Search')/x:div[2]/x:div/x:div[1]");
197 $this->waitForElementPresent("financial_type_id");
198 $this->select('financial_type_id',"label=Donation");
199 $this->click('_qf_Search_refresh');
201 $this->waitForPageToLoad($this->getTimeoutMsec());
202 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
204 $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
205 $this->waitForPageToLoad($this->getTimeoutMsec());
206 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
208 'From' => "{$firstName} {$lastName}",
209 'Financial Type' => 'Donation',
210 'Contribution Status' => 'Pending : Pay Later',
212 $this->webtestVerifyTabularData($expected);
213 $this->click('_qf_ContributionView_cancel-bottom');
217 $this->openCiviPage("member/search", "reset=1", 'member_source');
218 $this->type('sort_name', "$firstName $lastName");
219 $this->click('_qf_Search_refresh');
220 $this->waitForPageToLoad($this->getTimeoutMsec());
222 //visit the Member View link
223 $this->waitForElementPresent("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
224 $this->click("xpath=//div[@id='memberSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
225 $this->waitForPageToLoad($this->getTimeoutMsec());
226 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
228 //View Membership Record
230 'Member' => "{$firstName} {$lastName}",
231 'Membership Type' => 'Student',
232 'Status' => 'Pending',
234 $this->webtestVerifyTabularData($expected);
235 $this->click('_qf_MembershipView_cancel-bottom');