Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testAddEvent() { | |
6a488035 | 36 | // Log in using webtestLogin() method |
42daf119 | 37 | $this->webtestLogin('admin'); |
6a488035 | 38 | |
071a6d2e | 39 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
40 | |
41 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
42 | $eventDescription = "Here is a description for this conference."; | |
43 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
44 | ||
45 | $streetAddress = "100 Main Street"; | |
46 | $this->_testAddLocation($streetAddress); | |
47 | ||
48 | // intro text for registration page | |
49 | $registerIntro = "Fill in all the fields below and click Continue."; | |
50 | $multipleRegistrations = TRUE; | |
51 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
52 | ||
53 | // enable tell a friend | |
54 | $subject = "$eventTitle Tell A Friend"; | |
55 | $thankYouMsg = "$eventTitle Tell A Friend Test Thankyou Message"; | |
56 | $this->_testAddTellAFriend($subject, $thankYouMsg, $eventTitle); | |
57 | ||
58 | // get the url for registration | |
59 | $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']"); | |
60 | $this->click("link=$eventTitle"); | |
61 | $this->waitForElementPresent("link=Register Now"); | |
62 | $this->click("link=Register Now"); | |
63 | $this->waitForElementPresent("_qf_Register_upload-bottom"); | |
64 | $registerUrl = $this->getLocation(); | |
65 | ||
66 | // give permissions for event registration | |
67 | $permission = array('edit-1-register-for-events'); | |
68 | $this->changePermissions($permission); | |
69 | ||
70 | // register as an anonymous user | |
42daf119 | 71 | $this->webtestLogout(); |
6a488035 TO |
72 | $this->open($registerUrl); |
73 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
74 | ||
75 | $firstName = substr(sha1(rand()), 0, 7); | |
76 | $this->type('email-Primary', "$firstName@Anderson.com"); | |
77 | $this->click('_qf_Register_upload-bottom'); | |
78 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
79 | $this->click("css=div.crm-event-thankyou-form-block div#tell-a-friend a"); | |
80 | $this->waitForElementPresent('_qf_Form_cancel'); | |
81 | ||
82 | $this->type('suggested_message', '$subject Test Message for the recipients'); | |
83 | ||
84 | // fill the recipients | |
85 | $firstName1 = 'John' . substr(sha1(rand()), 0, 7); | |
86 | $lastName1 = substr(sha1(rand()), 0, 7); | |
87 | $this->type('friend_1_first_name', "$firstName1"); | |
88 | $this->type('friend_1_last_name', "$lastName1"); | |
89 | $this->type('friend_1_email', "$firstName1@$lastName1.com"); | |
90 | ||
91 | $firstName2 = 'Smith' . substr(sha1(rand()), 0, 7); | |
92 | $lastName2 = substr(sha1(rand()), 0, 7); | |
93 | $this->type('friend_2_first_name', "$firstName2"); | |
94 | $this->type('friend_2_last_name', "$lastName2"); | |
95 | $this->type('friend_2_email', "$firstName2@$lastName2.com"); | |
96 | ||
97 | $firstName3 = 'James' . substr(sha1(rand()), 0, 7); | |
98 | $lastName3 = substr(sha1(rand()), 0, 7); | |
99 | $this->type('friend_3_first_name', "$firstName3"); | |
100 | $this->type('friend_3_last_name', "$lastName3"); | |
101 | $this->type('friend_3_email', "$firstName3@$lastName3.com"); | |
102 | ||
103 | $this->click('_qf_Form_submit'); | |
104 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
105 | ||
efb29358 | 106 | $this->waitForTextPresent($thankYouMsg); |
6a488035 TO |
107 | |
108 | // Log in using webtestLogin() method | |
6a488035 TO |
109 | $this->webtestLogin(); |
110 | ||
111 | // get all friends contact id | |
42daf119 | 112 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
113 | $this->type('sort_name', $firstName1); |
114 | $this->click('_qf_Basic_refresh '); | |
115 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
116 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); | |
117 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
118 | ||
42daf119 | 119 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
120 | $this->type('sort_name', $firstName2); |
121 | $this->click('_qf_Basic_refresh '); | |
122 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
123 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); | |
124 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
125 | ||
42daf119 | 126 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
127 | $this->type('sort_name', $firstName3); |
128 | $this->click('_qf_Basic_refresh '); | |
129 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
130 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); | |
131 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
132 | ||
42daf119 | 133 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
134 | $this->type('sort_name', $firstName); |
135 | $this->click('_qf_Basic_refresh '); | |
136 | $this->waitForElementPresent('Print'); | |
137 | $this->assertTrue($this->isTextPresent('1 Contact')); | |
138 | ||
139 | // Verify Activity created | |
42daf119 | 140 | $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh'); |
6a488035 TO |
141 | $this->type('sort_name', $firstName1); |
142 | $this->click('_qf_Search_refresh'); | |
143 | $this->waitForElementPresent("_qf_Search_next_print"); | |
144 | $this->click("xpath=//div[@class='crm-search-results']//table[@class='selector']/tbody/tr[2]/td[9]/span/a[text()='View']"); | |
145 | $this->waitForElementPresent('_qf_Activity_cancel-bottom'); | |
146 | ||
147 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[1]/td[2]", | |
148 | preg_quote("$firstName@Anderson.com") | |
149 | ); | |
150 | ||
151 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[1]", | |
152 | preg_quote("$lastName1, $firstName1") | |
153 | ); | |
154 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[2]", | |
155 | preg_quote("$lastName2, $firstName2") | |
156 | ); | |
157 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[3]", | |
158 | preg_quote("$lastName3, $firstName3") | |
159 | ); | |
160 | ||
161 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[4]/td[2]", | |
162 | preg_quote("Tell a Friend:") | |
163 | ); | |
164 | } | |
165 | ||
166 | function _testAddEventInfo($eventTitle, $eventDescription) { | |
6a488035 TO |
167 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
168 | ||
6a488035 TO |
169 | $this->select("event_type_id", "value=1"); |
170 | ||
171 | // Attendee role s/b selected now. | |
172 | $this->select("default_role_id", "value=1"); | |
173 | ||
174 | // Enter Event Title, Summary and Description | |
175 | $this->type("title", $eventTitle); | |
176 | $this->type("summary", "This is a great conference. Sign up now!"); | |
177 | ||
178 | // Type description in ckEditor (fieldname, text to type, editor) | |
179 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
180 | ||
181 | // Choose Start and End dates. | |
182 | // Using helper webtestFillDate function. | |
183 | $this->webtestFillDateTime("start_date", "+1 week"); | |
184 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
185 | ||
186 | $this->type("max_participants", "50"); | |
187 | $this->click("is_map"); | |
188 | $this->click("_qf_EventInfo_upload-bottom"); | |
189 | } | |
190 | ||
191 | function _testAddLocation($streetAddress) { | |
192 | // Wait for Location tab form to load | |
193 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
194 | $this->waitForElementPresent("_qf_Location_upload-bottom"); | |
195 | ||
196 | // Fill in address fields | |
197 | $streetAddress = "100 Main Street"; | |
198 | $this->type("address_1_street_address", $streetAddress); | |
199 | $this->type("address_1_city", "San Francisco"); | |
200 | $this->type("address_1_postal_code", "94117"); | |
201 | $this->select("address_1_state_province_id", "value=1004"); | |
202 | $this->type("email_1_email", "info@civicrm.org"); | |
203 | ||
204 | $this->click("_qf_Location_upload-bottom"); | |
205 | ||
206 | // Wait for "saved" status msg | |
207 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
208 | $this->waitForTextPresent("'Location' information has been saved."); | |
209 | } | |
210 | ||
211 | function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) { | |
212 | // Go to Online Registration tab | |
213 | $this->click("link=Online Registration"); | |
214 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
215 | ||
216 | $this->check("is_online_registration"); | |
217 | $this->assertChecked("is_online_registration"); | |
218 | if ($multipleRegistrations) { | |
219 | $this->check("is_multiple_registrations"); | |
220 | $this->assertChecked("is_multiple_registrations"); | |
221 | } | |
222 | ||
223 | $this->fillRichTextField("intro_text", $registerIntro); | |
224 | ||
225 | // enable confirmation email | |
226 | $this->click('xpath=//fieldset[@id="mail"]/div/table/tbody/tr/td[2]/label[contains(text(), "Yes")]'); | |
227 | $this->type("confirm_from_name", "Jane Doe"); | |
228 | $this->type("confirm_from_email", "jane.doe@example.org"); | |
229 | ||
230 | $this->click("_qf_Registration_upload-bottom"); | |
231 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
232 | $this->waitForTextPresent("'Registration' information has been saved."); | |
233 | } | |
234 | ||
235 | function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) { | |
236 | // Go to Tell A Friend Tab | |
237 | $this->click('link=Tell a Friend'); | |
238 | $this->waitForElementPresent('_qf_Event_cancel-bottom'); | |
239 | ||
240 | // Enable tell a friend feature | |
241 | $this->check('tf_is_active'); | |
242 | $this->waitForElementPresent('tf_thankyou_text'); | |
243 | ||
244 | // Modify the messages | |
245 | $this->type('intro', "This is $subject Test intro text"); | |
246 | $this->type('suggested_message', "$subject Test Message. This is amazing!"); | |
247 | ||
248 | $this->type('tf_thankyou_title', 'Test thank you title'); | |
249 | $this->type('tf_thankyou_text', $thankYouMsg); | |
250 | ||
251 | $this->click('_qf_Event_upload_done-bottom'); | |
252 | $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']"); | |
253 | } | |
254 | } | |
255 |