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