Start migrating to use clickLink method
[civicrm-core.git] / tests / phpunit / WebTest / Event / EventWaitListTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC (c) 2004-2013 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
7 | |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
11 | |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Affero General Public |
18 | License along with this program; if not, contact CiviCRM LLC |
19 | at info[AT]civicrm[DOT]org. If you have questions about the |
20 | GNU Affero General Public License or the licensing of CiviCRM, |
21 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
22 +--------------------------------------------------------------------+
23*/
24
25
26require_once 'CiviTest/CiviSeleniumTestCase.php';
27class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase {
28
29 protected function setUp() {
30 parent::setUp();
31 }
32
33 function testEventWaitList() {
6a488035
TO
34 // Log in using webtestLogin() method
35 $this->webtestLogin();
36
37 // We need a payment processor
38 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
39 $this->webtestAddPaymentProcessor($processorName);
40
071a6d2e 41 $this->openCiviPage("event/add", "reset=1&action=add");
6a488035
TO
42
43 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
44 $eventDescription = "Here is a description for this conference.";
6a488035
TO
45 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
46
6a488035
TO
47 $this->select("event_type_id", "value=1");
48
49 // Attendee role s/b selected now.
50 $this->select("default_role_id", "value=1");
51
52 // Enter Event Title, Summary and Description
53 $this->type("title", $eventTitle);
54 $this->type("summary", "This is a great conference. Sign up now!");
55
56 // Type description in ckEditor (fieldname, text to type, editor)
57 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
58
59 // Choose Start and End dates.
60 // Using helper webtestFillDate function.
61 $this->webtestFillDateTime("start_date", "+1 week");
62 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
63
64 $this->type("max_participants", "6");
65 $this->click("is_map");
66 $this->click("_qf_EventInfo_upload-bottom");
67
68 $streetAddress = "100 Main Street";
69
70 // Wait for Location tab form to load
71 $this->waitForPageToLoad($this->getTimeoutMsec());
72 $this->waitForElementPresent("_qf_Location_upload-bottom");
73
74 // Fill in address fields
75 $streetAddress = "100 Main Street";
76 $this->type("address_1_street_address", $streetAddress);
77 $this->type("address_1_city", "San Francisco");
78 $this->type("address_1_postal_code", "94117");
79 $this->select("address_1_state_province_id", "value=1004");
80 $this->type("email_1_email", "info@civicrm.org");
81
82 $this->click("_qf_Location_upload-bottom");
83
84 // Wait for "saved" status msg
85 $this->waitForPageToLoad($this->getTimeoutMsec());
86 $this->waitForTextPresent("'Location' information has been saved.");
87
88 // Go to Fees tab
89 $this->click("link=Fees");
90 $this->waitForElementPresent("_qf_Fee_upload-bottom");
91 $this->click("CIVICRM_QFID_1_is_monetary");
92 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
93
94 $this->select("financial_type_id", "Donation");
95 $this->type("label_1", "Member");
96 $this->type("value_1", "250.00");
97 $this->type("label_2", "Non-member");
98 $this->type("value_2", "325.00");
99 //set default
100 $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
101
102 $this->click("_qf_Fee_upload-bottom");
103
104 // Wait for "saved" status msg
105 $this->waitForPageToLoad($this->getTimeoutMsec());
106 $this->waitForTextPresent("'Fee' information has been saved.");
107
108 // intro text for registration page
109 $registerIntro = "Fill in all the fields below and click Continue.";
110 $multipleRegistrations = TRUE;
111
112 // Go to Online Registration tab
113 $this->click("link=Online Registration");
114 $this->waitForElementPresent("_qf_Registration_upload-bottom");
115 $this->isTextPresent("BCC Confirmation To");
116 $this->check("is_online_registration");
117 $this->assertChecked("is_online_registration");
118 if ($multipleRegistrations) {
119 $this->check("is_multiple_registrations");
120 $this->assertChecked("is_multiple_registrations");
121 }
122
123 $this->fillRichTextField("intro_text", $registerIntro);
124
125 // enable confirmation email
126 $this->click("CIVICRM_QFID_1_is_email_confirm");
127 $this->type("confirm_from_name", "Jane Doe");
128 $this->type("confirm_from_email", "jane.doe@example.org");
129
130 $this->click("_qf_Registration_upload-bottom");
131 $this->waitForPageToLoad($this->getTimeoutMsec());
132 $this->waitForTextPresent("'Registration' information has been saved.");
133
134 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
135 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
136
137 $registerStrings = array("250.00", "Member", "325.00", "Non-member");
138 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
139
140 $numberRegistrations = 2;
141 $anonymous = TRUE;
142 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
143
144 $numberRegistrations = 2;
145 $anonymous = TRUE;
146 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
147
148 //check whether event is full
149 $this->open($registerUrl);
150 $this->assertStringsPresent("This event is currently full.");
151 }
152
153 function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
154 // verify event input on info page
155 // start at Manage Events listing
071a6d2e 156 $this->openCiviPage("event/manage", "reset=1");
225a8648 157 $this->clickLink("link=$eventTitle", "link=Register Now");
6a488035
TO
158
159 // Check for correct event info strings
160 $this->assertStringsPresent($eventInfoStrings);
161 }
162
163 function _testVerifyRegisterPage($registerStrings) {
164 // Go to Register page and check for intro text and fee levels
165 $this->click("link=Register Now");
166 $this->waitForElementPresent("_qf_Register_upload-bottom");
167 $this->assertStringsPresent($registerStrings);
168 return $this->getLocation();
169 }
170
171 function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
172 if ($anonymous) {
42daf119 173 $this->webtestLogout();
6a488035
TO
174 }
175 $this->open($registerUrl);
176
177 $this->select("additional_participants", "value=" . $numberRegistrations);
178 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
179
180 $this->select("credit_card_type", "value=Visa");
181 $this->type("credit_card_number", "4111111111111111");
182 $this->type("cvv2", "000");
183 $this->select("credit_card_exp_date[M]", "value=1");
184 $this->select("credit_card_exp_date[Y]", "value=2020");
185 $this->type("billing_first_name", "Jane");
186 $this->type("billing_last_name", "Smith" . substr(sha1(rand()), 0, 7));
187 $this->type("billing_street_address-5", "15 Main St.");
188 $this->type(" billing_city-5", "San Jose");
189 $this->select("billing_country_id-5", "value=1228");
190 $this->select("billing_state_province_id-5", "value=1004");
191 $this->type("billing_postal_code-5", "94129");
192
193 $this->click("_qf_Register_upload-bottom");
194
195 if ($numberRegistrations > 1) {
196 for ($i = 1; $i <= $numberRegistrations; $i++) {
197 $this->waitForPageToLoad($this->getTimeoutMsec());
198 // Look for continue button
199 $this->waitForElementPresent("_qf_Participant_{$i}_next");
200 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
201 $this->click("_qf_Participant_{$i}_next");
202 }
203 }
204 $this->waitForPageToLoad($this->getTimeoutMsec());
205 $this->waitForElementPresent("_qf_Confirm_next-bottom");
206 $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information");
207 $this->assertStringsPresent($confirmStrings);
208 $this->click("_qf_Confirm_next-bottom");
209 $this->waitForPageToLoad($this->getTimeoutMsec());
210 $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date");
211 $this->assertStringsPresent($thankStrings);
212
213 if ($anonymous) {
214 // log back in so we're in the same state
6a488035
TO
215 $this->webtestLogin();
216 }
217 }
218}
219