Update Copywrite year to be 2019
[civicrm-core.git] / tests / phpunit / WebTest / Event / EventWaitListTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
6b83d5bd 4 | Copyright CiviCRM LLC (c) 2004-2019 |
6a488035
TO
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 +--------------------------------------------------------------------+
d25dd0ee 23 */
6a488035 24
6a488035 25require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
26
27/**
28 * Class WebTest_Event_EventWaitListTest
29 */
6a488035
TO
30class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase {
31
32 protected function setUp() {
33 parent::setUp();
34 }
35
00be9182 36 public function testEventWaitList() {
6a488035
TO
37 // Log in using webtestLogin() method
38 $this->webtestLogin();
39
c3ad8633
CW
40 // Use default payment processor
41 $processorName = 'Test Processor';
6a488035
TO
42 $this->webtestAddPaymentProcessor($processorName);
43
071a6d2e 44 $this->openCiviPage("event/add", "reset=1&action=add");
6a488035
TO
45
46 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
47 $eventDescription = "Here is a description for this conference.";
6a488035
TO
48 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
49
6a488035
TO
50 $this->select("event_type_id", "value=1");
51
52 // Attendee role s/b selected now.
53 $this->select("default_role_id", "value=1");
54
55 // Enter Event Title, Summary and Description
56 $this->type("title", $eventTitle);
57 $this->type("summary", "This is a great conference. Sign up now!");
58
59 // Type description in ckEditor (fieldname, text to type, editor)
60 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
61
62 // Choose Start and End dates.
63 // Using helper webtestFillDate function.
64 $this->webtestFillDateTime("start_date", "+1 week");
65 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
66
67 $this->type("max_participants", "6");
68 $this->click("is_map");
69 $this->click("_qf_EventInfo_upload-bottom");
70
71 $streetAddress = "100 Main Street";
72
73 // Wait for Location tab form to load
74 $this->waitForPageToLoad($this->getTimeoutMsec());
75 $this->waitForElementPresent("_qf_Location_upload-bottom");
76
77 // Fill in address fields
78 $streetAddress = "100 Main Street";
79 $this->type("address_1_street_address", $streetAddress);
80 $this->type("address_1_city", "San Francisco");
81 $this->type("address_1_postal_code", "94117");
86797006 82 $this->select('address_1_country_id', 'UNITED STATES');
6a488035
TO
83 $this->select("address_1_state_province_id", "value=1004");
84 $this->type("email_1_email", "info@civicrm.org");
85
86 $this->click("_qf_Location_upload-bottom");
87
88 // Wait for "saved" status msg
0ecb5006 89 $this->waitForElementPresent("_qf_Location_upload-bottom");
90 $this->waitForTextPresent("'Event Location' information has been saved.");
6a488035
TO
91
92 // Go to Fees tab
93 $this->click("link=Fees");
94 $this->waitForElementPresent("_qf_Fee_upload-bottom");
95 $this->click("CIVICRM_QFID_1_is_monetary");
a90dac23 96 $this->select2('payment_processor', $processorName, TRUE);
6a488035
TO
97 $this->select("financial_type_id", "Donation");
98 $this->type("label_1", "Member");
99 $this->type("value_1", "250.00");
100 $this->type("label_2", "Non-member");
101 $this->type("value_2", "325.00");
102 //set default
103 $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
104
105 $this->click("_qf_Fee_upload-bottom");
106
107 // Wait for "saved" status msg
0ecb5006 108 $this->waitForElementPresent("_qf_Fee_upload-bottom");
109 $this->waitForTextPresent("'Fees' information has been saved.");
6a488035
TO
110
111 // intro text for registration page
112 $registerIntro = "Fill in all the fields below and click Continue.";
113 $multipleRegistrations = TRUE;
114
115 // Go to Online Registration tab
116 $this->click("link=Online Registration");
117 $this->waitForElementPresent("_qf_Registration_upload-bottom");
118 $this->isTextPresent("BCC Confirmation To");
119 $this->check("is_online_registration");
120 $this->assertChecked("is_online_registration");
121 if ($multipleRegistrations) {
122 $this->check("is_multiple_registrations");
123 $this->assertChecked("is_multiple_registrations");
124 }
125
895231b4 126 $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
6a488035
TO
127
128 // enable confirmation email
129 $this->click("CIVICRM_QFID_1_is_email_confirm");
130 $this->type("confirm_from_name", "Jane Doe");
131 $this->type("confirm_from_email", "jane.doe@example.org");
132
133 $this->click("_qf_Registration_upload-bottom");
0ecb5006 134 $this->waitForElementPresent("_qf_Registration_upload-bottom");
135 $this->waitForTextPresent("'Online Registration' information has been saved.");
6a488035
TO
136
137 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
138 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
139
140 $registerStrings = array("250.00", "Member", "325.00", "Non-member");
141 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
142
143 $numberRegistrations = 2;
144 $anonymous = TRUE;
145 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
146
147 $numberRegistrations = 2;
148 $anonymous = TRUE;
149 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
150
151 //check whether event is full
152 $this->open($registerUrl);
153 $this->assertStringsPresent("This event is currently full.");
154 }
155
4cbe18b8
EM
156 /**
157 * @param $eventTitle
158 * @param $eventInfoStrings
159 */
00be9182 160 public function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
6a488035
TO
161 // verify event input on info page
162 // start at Manage Events listing
071a6d2e 163 $this->openCiviPage("event/manage", "reset=1");
225a8648 164 $this->clickLink("link=$eventTitle", "link=Register Now");
6a488035
TO
165
166 // Check for correct event info strings
167 $this->assertStringsPresent($eventInfoStrings);
168 }
169
4cbe18b8
EM
170 /**
171 * @param $registerStrings
172 *
173 * @return string
174 */
00be9182 175 public function _testVerifyRegisterPage($registerStrings) {
6a488035
TO
176 // Go to Register page and check for intro text and fee levels
177 $this->click("link=Register Now");
178 $this->waitForElementPresent("_qf_Register_upload-bottom");
179 $this->assertStringsPresent($registerStrings);
180 return $this->getLocation();
181 }
182
4cbe18b8
EM
183 /**
184 * @param $registerUrl
185 * @param int $numberRegistrations
186 * @param bool $anonymous
187 */
00be9182 188 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
6a488035 189 if ($anonymous) {
42daf119 190 $this->webtestLogout();
6a488035
TO
191 }
192 $this->open($registerUrl);
193
194 $this->select("additional_participants", "value=" . $numberRegistrations);
1f65e71e 195 $this->type("first_name", "Jane");
196 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
197 $this->type("last_name", $lastName);
6a488035
TO
198 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
199
200 $this->select("credit_card_type", "value=Visa");
201 $this->type("credit_card_number", "4111111111111111");
202 $this->type("cvv2", "000");
203 $this->select("credit_card_exp_date[M]", "value=1");
204 $this->select("credit_card_exp_date[Y]", "value=2020");
205 $this->type("billing_first_name", "Jane");
1f65e71e 206 $this->type("billing_last_name", $lastName);
6a488035
TO
207 $this->type("billing_street_address-5", "15 Main St.");
208 $this->type(" billing_city-5", "San Jose");
209 $this->select("billing_country_id-5", "value=1228");
210 $this->select("billing_state_province_id-5", "value=1004");
211 $this->type("billing_postal_code-5", "94129");
212
213 $this->click("_qf_Register_upload-bottom");
214
215 if ($numberRegistrations > 1) {
216 for ($i = 1; $i <= $numberRegistrations; $i++) {
217 $this->waitForPageToLoad($this->getTimeoutMsec());
218 // Look for continue button
219 $this->waitForElementPresent("_qf_Participant_{$i}_next");
1f65e71e 220 $this->type("first_name", "Jane Add {$i}");
221 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
222 $this->type("last_name", $lastName);
6a488035
TO
223 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
224 $this->click("_qf_Participant_{$i}_next");
225 }
226 }
227 $this->waitForPageToLoad($this->getTimeoutMsec());
228 $this->waitForElementPresent("_qf_Confirm_next-bottom");
229 $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information");
230 $this->assertStringsPresent($confirmStrings);
231 $this->click("_qf_Confirm_next-bottom");
232 $this->waitForPageToLoad($this->getTimeoutMsec());
233 $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date");
234 $this->assertStringsPresent($thankStrings);
235
236 if ($anonymous) {
237 // log back in so we're in the same state
6a488035
TO
238 $this->webtestLogin();
239 }
240 }
96025800 241
6a488035 242}