3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC (c) 2004-2016 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
25 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 * Class WebTest_Event_EventWaitListTest
30 class WebTest_Event_EventWaitListTest
extends CiviSeleniumTestCase
{
32 protected function setUp() {
36 public function testEventWaitList() {
37 // Log in using webtestLogin() method
38 $this->webtestLogin();
40 // Use default payment processor
41 $processorName = 'Test Processor';
42 $this->webtestAddPaymentProcessor($processorName);
44 $this->openCiviPage("event/add", "reset=1&action=add");
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");
50 $this->select("event_type_id", "value=1");
52 // Attendee role s/b selected now.
53 $this->select("default_role_id", "value=1");
55 // Enter Event Title, Summary and Description
56 $this->type("title", $eventTitle);
57 $this->type("summary", "This is a great conference. Sign up now!");
59 // Type description in ckEditor (fieldname, text to type, editor)
60 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
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 ");
67 $this->type("max_participants", "6");
68 $this->click("is_map");
69 $this->click("_qf_EventInfo_upload-bottom");
71 $streetAddress = "100 Main Street";
73 // Wait for Location tab form to load
74 $this->waitForPageToLoad($this->getTimeoutMsec());
75 $this->waitForElementPresent("_qf_Location_upload-bottom");
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");
86 $this->click("_qf_Location_upload-bottom");
88 // Wait for "saved" status msg
89 $this->waitForElementPresent("_qf_Location_upload-bottom");
90 $this->waitForTextPresent("'Event Location' information has been saved.");
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 $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");
103 $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
105 $this->click("_qf_Fee_upload-bottom");
107 // Wait for "saved" status msg
108 $this->waitForElementPresent("_qf_Fee_upload-bottom");
109 $this->waitForTextPresent("'Fees' information has been saved.");
111 // intro text for registration page
112 $registerIntro = "Fill in all the fields below and click Continue.";
113 $multipleRegistrations = TRUE;
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");
126 $this->fillRichTextField('intro_text', $registerIntro, 'CKEditor', TRUE);
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");
133 $this->click("_qf_Registration_upload-bottom");
134 $this->waitForElementPresent("_qf_Registration_upload-bottom");
135 $this->waitForTextPresent("'Online Registration' information has been saved.");
137 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
138 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
140 $registerStrings = array("250.00", "Member", "325.00", "Non-member");
141 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
143 $numberRegistrations = 2;
145 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
147 $numberRegistrations = 2;
149 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
151 //check whether event is full
152 $this->open($registerUrl);
153 $this->assertStringsPresent("This event is currently full.");
158 * @param $eventInfoStrings
160 public function _testVerifyEventInfo($eventTitle, $eventInfoStrings) {
161 // verify event input on info page
162 // start at Manage Events listing
163 $this->openCiviPage("event/manage", "reset=1");
164 $this->clickLink("link=$eventTitle", "link=Register Now");
166 // Check for correct event info strings
167 $this->assertStringsPresent($eventInfoStrings);
171 * @param $registerStrings
175 public function _testVerifyRegisterPage($registerStrings) {
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();
184 * @param $registerUrl
185 * @param int $numberRegistrations
186 * @param bool $anonymous
188 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
190 $this->webtestLogout();
192 $this->open($registerUrl);
194 $this->select("additional_participants", "value=" . $numberRegistrations);
195 $this->type("first_name", "Jane");
196 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
197 $this->type("last_name", $lastName);
198 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
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");
206 $this->type("billing_last_name", $lastName);
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");
213 $this->click("_qf_Register_upload-bottom");
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");
220 $this->type("first_name", "Jane Add {$i}");
221 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
222 $this->type("last_name", $lastName);
223 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
224 $this->click("_qf_Participant_{$i}_next");
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);
237 // log back in so we're in the same state
238 $this->webtestLogin();