Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
23 | */ | |
24 | ||
6a488035 | 25 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
26 | |
27 | /** | |
28 | * Class WebTest_Event_EventWaitListTest | |
29 | */ | |
6a488035 TO |
30 | class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase { |
31 | ||
32 | protected function setUp() { | |
33 | parent::setUp(); | |
34 | } | |
35 | ||
36 | function testEventWaitList() { | |
6a488035 TO |
37 | // Log in using webtestLogin() method |
38 | $this->webtestLogin(); | |
39 | ||
40 | // We need a payment processor | |
41 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
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"); | |
82 | $this->select("address_1_state_province_id", "value=1004"); | |
83 | $this->type("email_1_email", "info@civicrm.org"); | |
84 | ||
85 | $this->click("_qf_Location_upload-bottom"); | |
86 | ||
87 | // Wait for "saved" status msg | |
0ecb5006 | 88 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
89 | $this->waitForTextPresent("'Event Location' information has been saved."); | |
6a488035 TO |
90 | |
91 | // Go to Fees tab | |
92 | $this->click("link=Fees"); | |
93 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
94 | $this->click("CIVICRM_QFID_1_is_monetary"); | |
95 | $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']"); | |
96 | ||
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 | ||
60709d21 | 126 | $this->click('intro_text-plain'); |
6a488035 TO |
127 | $this->fillRichTextField("intro_text", $registerIntro); |
128 | ||
129 | // enable confirmation email | |
130 | $this->click("CIVICRM_QFID_1_is_email_confirm"); | |
131 | $this->type("confirm_from_name", "Jane Doe"); | |
132 | $this->type("confirm_from_email", "jane.doe@example.org"); | |
133 | ||
134 | $this->click("_qf_Registration_upload-bottom"); | |
0ecb5006 | 135 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
136 | $this->waitForTextPresent("'Online Registration' information has been saved."); | |
6a488035 TO |
137 | |
138 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
139 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
140 | ||
141 | $registerStrings = array("250.00", "Member", "325.00", "Non-member"); | |
142 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
143 | ||
144 | $numberRegistrations = 2; | |
145 | $anonymous = TRUE; | |
146 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous); | |
147 | ||
148 | $numberRegistrations = 2; | |
149 | $anonymous = TRUE; | |
150 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous); | |
151 | ||
152 | //check whether event is full | |
153 | $this->open($registerUrl); | |
154 | $this->assertStringsPresent("This event is currently full."); | |
155 | } | |
156 | ||
4cbe18b8 EM |
157 | /** |
158 | * @param $eventTitle | |
159 | * @param $eventInfoStrings | |
160 | */ | |
6a488035 TO |
161 | function _testVerifyEventInfo($eventTitle, $eventInfoStrings) { |
162 | // verify event input on info page | |
163 | // start at Manage Events listing | |
071a6d2e | 164 | $this->openCiviPage("event/manage", "reset=1"); |
225a8648 | 165 | $this->clickLink("link=$eventTitle", "link=Register Now"); |
6a488035 TO |
166 | |
167 | // Check for correct event info strings | |
168 | $this->assertStringsPresent($eventInfoStrings); | |
169 | } | |
170 | ||
4cbe18b8 EM |
171 | /** |
172 | * @param $registerStrings | |
173 | * | |
174 | * @return string | |
175 | */ | |
6a488035 TO |
176 | function _testVerifyRegisterPage($registerStrings) { |
177 | // Go to Register page and check for intro text and fee levels | |
178 | $this->click("link=Register Now"); | |
179 | $this->waitForElementPresent("_qf_Register_upload-bottom"); | |
180 | $this->assertStringsPresent($registerStrings); | |
181 | return $this->getLocation(); | |
182 | } | |
183 | ||
4cbe18b8 EM |
184 | /** |
185 | * @param $registerUrl | |
186 | * @param int $numberRegistrations | |
187 | * @param bool $anonymous | |
188 | */ | |
6a488035 TO |
189 | function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { |
190 | if ($anonymous) { | |
42daf119 | 191 | $this->webtestLogout(); |
6a488035 TO |
192 | } |
193 | $this->open($registerUrl); | |
194 | ||
195 | $this->select("additional_participants", "value=" . $numberRegistrations); | |
1f65e71e | 196 | $this->type("first_name", "Jane"); |
197 | $lastName = "Smith" . substr(sha1(rand()), 0, 7); | |
198 | $this->type("last_name", $lastName); | |
6a488035 TO |
199 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); |
200 | ||
201 | $this->select("credit_card_type", "value=Visa"); | |
202 | $this->type("credit_card_number", "4111111111111111"); | |
203 | $this->type("cvv2", "000"); | |
204 | $this->select("credit_card_exp_date[M]", "value=1"); | |
205 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
206 | $this->type("billing_first_name", "Jane"); | |
1f65e71e | 207 | $this->type("billing_last_name", $lastName); |
6a488035 TO |
208 | $this->type("billing_street_address-5", "15 Main St."); |
209 | $this->type(" billing_city-5", "San Jose"); | |
210 | $this->select("billing_country_id-5", "value=1228"); | |
211 | $this->select("billing_state_province_id-5", "value=1004"); | |
212 | $this->type("billing_postal_code-5", "94129"); | |
213 | ||
214 | $this->click("_qf_Register_upload-bottom"); | |
215 | ||
216 | if ($numberRegistrations > 1) { | |
217 | for ($i = 1; $i <= $numberRegistrations; $i++) { | |
218 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
219 | // Look for continue button | |
220 | $this->waitForElementPresent("_qf_Participant_{$i}_next"); | |
1f65e71e | 221 | $this->type("first_name", "Jane Add {$i}"); |
222 | $lastName = "Smith" . substr(sha1(rand()), 0, 7); | |
223 | $this->type("last_name", $lastName); | |
6a488035 TO |
224 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); |
225 | $this->click("_qf_Participant_{$i}_next"); | |
226 | } | |
227 | } | |
228 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
229 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
230 | $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information"); | |
231 | $this->assertStringsPresent($confirmStrings); | |
232 | $this->click("_qf_Confirm_next-bottom"); | |
233 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
234 | $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date"); | |
235 | $this->assertStringsPresent($thankStrings); | |
236 | ||
237 | if ($anonymous) { | |
238 | // log back in so we're in the same state | |
6a488035 TO |
239 | $this->webtestLogin(); |
240 | } | |
241 | } | |
242 | } | |
243 |