Merge pull request #7181 from eileenmcnaughton/CRM-17335-2
[civicrm-core.git] / tests / phpunit / WebTest / Event / EventWaitListTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC (c) 2004-2015 |
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
26
27 /**
28 * Class WebTest_Event_EventWaitListTest
29 */
30 class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase {
31
32 protected function setUp() {
33 parent::setUp();
34 }
35
36 public function testEventWaitList() {
37 // Log in using webtestLogin() method
38 $this->webtestLogin();
39
40 // Use default payment processor
41 $processorName = 'Test Processor';
42 $this->webtestAddPaymentProcessor($processorName);
43
44 $this->openCiviPage("event/add", "reset=1&action=add");
45
46 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
47 $eventDescription = "Here is a description for this conference.";
48 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
49
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");
82 $this->select('address_1_country_id', 'UNITED STATES');
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
89 $this->waitForElementPresent("_qf_Location_upload-bottom");
90 $this->waitForTextPresent("'Event Location' information has been saved.");
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");
96 $this->select2('payment_processor', $processorName, TRUE);
97
98
99 $this->select("financial_type_id", "Donation");
100 $this->type("label_1", "Member");
101 $this->type("value_1", "250.00");
102 $this->type("label_2", "Non-member");
103 $this->type("value_2", "325.00");
104 //set default
105 $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
106
107 $this->click("_qf_Fee_upload-bottom");
108
109 // Wait for "saved" status msg
110 $this->waitForElementPresent("_qf_Fee_upload-bottom");
111 $this->waitForTextPresent("'Fees' information has been saved.");
112
113 // intro text for registration page
114 $registerIntro = "Fill in all the fields below and click Continue.";
115 $multipleRegistrations = TRUE;
116
117 // Go to Online Registration tab
118 $this->click("link=Online Registration");
119 $this->waitForElementPresent("_qf_Registration_upload-bottom");
120 $this->isTextPresent("BCC Confirmation To");
121 $this->check("is_online_registration");
122 $this->assertChecked("is_online_registration");
123 if ($multipleRegistrations) {
124 $this->check("is_multiple_registrations");
125 $this->assertChecked("is_multiple_registrations");
126 }
127
128 $this->click('intro_text');
129 $this->fillRichTextField("intro_text", $registerIntro);
130
131 // enable confirmation email
132 $this->click("CIVICRM_QFID_1_is_email_confirm");
133 $this->type("confirm_from_name", "Jane Doe");
134 $this->type("confirm_from_email", "jane.doe@example.org");
135
136 $this->click("_qf_Registration_upload-bottom");
137 $this->waitForElementPresent("_qf_Registration_upload-bottom");
138 $this->waitForTextPresent("'Online Registration' information has been saved.");
139
140 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
141 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
142
143 $registerStrings = array("250.00", "Member", "325.00", "Non-member");
144 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
145
146 $numberRegistrations = 2;
147 $anonymous = TRUE;
148 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
149
150 $numberRegistrations = 2;
151 $anonymous = TRUE;
152 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
153
154 //check whether event is full
155 $this->open($registerUrl);
156 $this->assertStringsPresent("This event is currently full.");
157 }
158
159 /**
160 * @param $eventTitle
161 * @param $eventInfoStrings
162 */
163 public function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
164 // verify event input on info page
165 // start at Manage Events listing
166 $this->openCiviPage("event/manage", "reset=1");
167 $this->clickLink("link=$eventTitle", "link=Register Now");
168
169 // Check for correct event info strings
170 $this->assertStringsPresent($eventInfoStrings);
171 }
172
173 /**
174 * @param $registerStrings
175 *
176 * @return string
177 */
178 public function _testVerifyRegisterPage($registerStrings) {
179 // Go to Register page and check for intro text and fee levels
180 $this->click("link=Register Now");
181 $this->waitForElementPresent("_qf_Register_upload-bottom");
182 $this->assertStringsPresent($registerStrings);
183 return $this->getLocation();
184 }
185
186 /**
187 * @param $registerUrl
188 * @param int $numberRegistrations
189 * @param bool $anonymous
190 */
191 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
192 if ($anonymous) {
193 $this->webtestLogout();
194 }
195 $this->open($registerUrl);
196
197 $this->select("additional_participants", "value=" . $numberRegistrations);
198 $this->type("first_name", "Jane");
199 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
200 $this->type("last_name", $lastName);
201 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
202
203 $this->select("credit_card_type", "value=Visa");
204 $this->type("credit_card_number", "4111111111111111");
205 $this->type("cvv2", "000");
206 $this->select("credit_card_exp_date[M]", "value=1");
207 $this->select("credit_card_exp_date[Y]", "value=2020");
208 $this->type("billing_first_name", "Jane");
209 $this->type("billing_last_name", $lastName);
210 $this->type("billing_street_address-5", "15 Main St.");
211 $this->type(" billing_city-5", "San Jose");
212 $this->select("billing_country_id-5", "value=1228");
213 $this->select("billing_state_province_id-5", "value=1004");
214 $this->type("billing_postal_code-5", "94129");
215
216 $this->click("_qf_Register_upload-bottom");
217
218 if ($numberRegistrations > 1) {
219 for ($i = 1; $i <= $numberRegistrations; $i++) {
220 $this->waitForPageToLoad($this->getTimeoutMsec());
221 // Look for continue button
222 $this->waitForElementPresent("_qf_Participant_{$i}_next");
223 $this->type("first_name", "Jane Add {$i}");
224 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
225 $this->type("last_name", $lastName);
226 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
227 $this->click("_qf_Participant_{$i}_next");
228 }
229 }
230 $this->waitForPageToLoad($this->getTimeoutMsec());
231 $this->waitForElementPresent("_qf_Confirm_next-bottom");
232 $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information");
233 $this->assertStringsPresent($confirmStrings);
234 $this->click("_qf_Confirm_next-bottom");
235 $this->waitForPageToLoad($this->getTimeoutMsec());
236 $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date");
237 $this->assertStringsPresent($thankStrings);
238
239 if ($anonymous) {
240 // log back in so we're in the same state
241 $this->webtestLogin();
242 }
243 }
244
245 }