Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Event_TellAFriendTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testAddEvent() { | |
6a488035 | 39 | // Log in using webtestLogin() method |
42daf119 | 40 | $this->webtestLogin('admin'); |
6a488035 | 41 | |
071a6d2e | 42 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
43 | |
44 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
45 | $eventDescription = "Here is a description for this conference."; | |
46 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
47 | ||
48 | $streetAddress = "100 Main Street"; | |
49 | $this->_testAddLocation($streetAddress); | |
50 | ||
51 | // intro text for registration page | |
52 | $registerIntro = "Fill in all the fields below and click Continue."; | |
53 | $multipleRegistrations = TRUE; | |
54 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
55 | ||
56 | // enable tell a friend | |
57 | $subject = "$eventTitle Tell A Friend"; | |
58 | $thankYouMsg = "$eventTitle Tell A Friend Test Thankyou Message"; | |
59 | $this->_testAddTellAFriend($subject, $thankYouMsg, $eventTitle); | |
60 | ||
61 | // get the url for registration | |
673c7418 | 62 | $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']"); |
6a488035 TO |
63 | $this->click("link=$eventTitle"); |
64 | $this->waitForElementPresent("link=Register Now"); | |
65 | $this->click("link=Register Now"); | |
66 | $this->waitForElementPresent("_qf_Register_upload-bottom"); | |
67 | $registerUrl = $this->getLocation(); | |
68 | ||
69 | // give permissions for event registration | |
70 | $permission = array('edit-1-register-for-events'); | |
71 | $this->changePermissions($permission); | |
72 | ||
73 | // register as an anonymous user | |
42daf119 | 74 | $this->webtestLogout(); |
6a488035 TO |
75 | $this->open($registerUrl); |
76 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
77 | ||
2325644f | 78 | $firstName = 'Jane' .substr(sha1(rand()), 0, 7); |
79 | $lastName = 'Doe' . substr(sha1(rand()), 0, 7); | |
80 | $this->type('first_name', "$firstName"); | |
81 | $this->type('last_name', "$lastName"); | |
82 | $this->type('email-Primary', "$firstName@$lastName.com"); | |
6a488035 TO |
83 | $this->click('_qf_Register_upload-bottom'); |
84 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
673c7418 | 85 | $this->click('_qf_Confirm_next-bottom'); |
86 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6a488035 TO |
87 | $this->click("css=div.crm-event-thankyou-form-block div#tell-a-friend a"); |
88 | $this->waitForElementPresent('_qf_Form_cancel'); | |
89 | ||
90 | $this->type('suggested_message', '$subject Test Message for the recipients'); | |
91 | ||
92 | // fill the recipients | |
93 | $firstName1 = 'John' . substr(sha1(rand()), 0, 7); | |
94 | $lastName1 = substr(sha1(rand()), 0, 7); | |
95 | $this->type('friend_1_first_name', "$firstName1"); | |
96 | $this->type('friend_1_last_name', "$lastName1"); | |
97 | $this->type('friend_1_email', "$firstName1@$lastName1.com"); | |
98 | ||
99 | $firstName2 = 'Smith' . substr(sha1(rand()), 0, 7); | |
100 | $lastName2 = substr(sha1(rand()), 0, 7); | |
101 | $this->type('friend_2_first_name', "$firstName2"); | |
102 | $this->type('friend_2_last_name', "$lastName2"); | |
103 | $this->type('friend_2_email', "$firstName2@$lastName2.com"); | |
104 | ||
105 | $firstName3 = 'James' . substr(sha1(rand()), 0, 7); | |
106 | $lastName3 = substr(sha1(rand()), 0, 7); | |
107 | $this->type('friend_3_first_name', "$firstName3"); | |
108 | $this->type('friend_3_last_name', "$lastName3"); | |
109 | $this->type('friend_3_email', "$firstName3@$lastName3.com"); | |
110 | ||
111 | $this->click('_qf_Form_submit'); | |
112 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
113 | ||
efb29358 | 114 | $this->waitForTextPresent($thankYouMsg); |
6a488035 TO |
115 | |
116 | // Log in using webtestLogin() method | |
6a488035 TO |
117 | $this->webtestLogin(); |
118 | ||
119 | // get all friends contact id | |
42daf119 | 120 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
121 | $this->type('sort_name', $firstName1); |
122 | $this->click('_qf_Basic_refresh '); | |
123 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
124 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); | |
125 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
126 | ||
42daf119 | 127 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
128 | $this->type('sort_name', $firstName2); |
129 | $this->click('_qf_Basic_refresh '); | |
130 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
131 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); | |
132 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
133 | ||
42daf119 | 134 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
135 | $this->type('sort_name', $firstName3); |
136 | $this->click('_qf_Basic_refresh '); | |
137 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
138 | $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); | |
139 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
140 | ||
42daf119 | 141 | $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); |
6a488035 TO |
142 | $this->type('sort_name', $firstName); |
143 | $this->click('_qf_Basic_refresh '); | |
60709d21 | 144 | $this->waitForTextPresent('1 Contact'); |
6a488035 TO |
145 | |
146 | // Verify Activity created | |
42daf119 | 147 | $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh'); |
6a488035 TO |
148 | $this->type('sort_name', $firstName1); |
149 | $this->click('_qf_Search_refresh'); | |
60709d21 | 150 | $this->waitForElementPresent("xpath=//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[text()='View']"); |
ed174dea | 151 | $this->click("xpath=//div[@class='crm-search-results']//table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[text()='View']"); |
6a488035 | 152 | $this->waitForElementPresent('_qf_Activity_cancel-bottom'); |
ed174dea | 153 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[1]/td[2]/span/a[1]", |
2325644f | 154 | preg_quote("$lastName, $firstName") |
6a488035 TO |
155 | ); |
156 | ||
beb98747 | 157 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span", |
6a488035 TO |
158 | preg_quote("$lastName1, $firstName1") |
159 | ); | |
beb98747 | 160 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span", |
6a488035 TO |
161 | preg_quote("$lastName2, $firstName2") |
162 | ); | |
beb98747 | 163 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/span", |
6a488035 TO |
164 | preg_quote("$lastName3, $firstName3") |
165 | ); | |
166 | ||
ed174dea | 167 | $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[4]/td[2]/span", |
6a488035 TO |
168 | preg_quote("Tell a Friend:") |
169 | ); | |
170 | } | |
171 | ||
4cbe18b8 EM |
172 | /** |
173 | * @param $eventTitle | |
174 | * @param $eventDescription | |
175 | */ | |
6a488035 | 176 | function _testAddEventInfo($eventTitle, $eventDescription) { |
6a488035 TO |
177 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
178 | ||
6a488035 TO |
179 | $this->select("event_type_id", "value=1"); |
180 | ||
181 | // Attendee role s/b selected now. | |
182 | $this->select("default_role_id", "value=1"); | |
183 | ||
184 | // Enter Event Title, Summary and Description | |
185 | $this->type("title", $eventTitle); | |
186 | $this->type("summary", "This is a great conference. Sign up now!"); | |
187 | ||
188 | // Type description in ckEditor (fieldname, text to type, editor) | |
189 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
190 | ||
191 | // Choose Start and End dates. | |
192 | // Using helper webtestFillDate function. | |
193 | $this->webtestFillDateTime("start_date", "+1 week"); | |
194 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
195 | ||
196 | $this->type("max_participants", "50"); | |
197 | $this->click("is_map"); | |
198 | $this->click("_qf_EventInfo_upload-bottom"); | |
199 | } | |
200 | ||
4cbe18b8 EM |
201 | /** |
202 | * @param $streetAddress | |
203 | */ | |
6a488035 TO |
204 | function _testAddLocation($streetAddress) { |
205 | // Wait for Location tab form to load | |
206 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
207 | $this->waitForElementPresent("_qf_Location_upload-bottom"); | |
208 | ||
209 | // Fill in address fields | |
210 | $streetAddress = "100 Main Street"; | |
211 | $this->type("address_1_street_address", $streetAddress); | |
212 | $this->type("address_1_city", "San Francisco"); | |
213 | $this->type("address_1_postal_code", "94117"); | |
214 | $this->select("address_1_state_province_id", "value=1004"); | |
215 | $this->type("email_1_email", "info@civicrm.org"); | |
216 | ||
217 | $this->click("_qf_Location_upload-bottom"); | |
218 | ||
219 | // Wait for "saved" status msg | |
ed174dea | 220 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
221 | $this->waitForTextPresent("'Event Location' information has been saved."); | |
6a488035 TO |
222 | } |
223 | ||
4cbe18b8 EM |
224 | /** |
225 | * @param $registerIntro | |
226 | * @param bool $multipleRegistrations | |
227 | */ | |
6a488035 TO |
228 | function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) { |
229 | // Go to Online Registration tab | |
230 | $this->click("link=Online Registration"); | |
231 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
232 | ||
233 | $this->check("is_online_registration"); | |
234 | $this->assertChecked("is_online_registration"); | |
235 | if ($multipleRegistrations) { | |
236 | $this->check("is_multiple_registrations"); | |
237 | $this->assertChecked("is_multiple_registrations"); | |
238 | } | |
239 | ||
60709d21 | 240 | $this->click('intro_text-plain'); |
6a488035 TO |
241 | $this->fillRichTextField("intro_text", $registerIntro); |
242 | ||
243 | // enable confirmation email | |
244 | $this->click('xpath=//fieldset[@id="mail"]/div/table/tbody/tr/td[2]/label[contains(text(), "Yes")]'); | |
245 | $this->type("confirm_from_name", "Jane Doe"); | |
246 | $this->type("confirm_from_email", "jane.doe@example.org"); | |
247 | ||
248 | $this->click("_qf_Registration_upload-bottom"); | |
ed174dea | 249 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
250 | $this->waitForTextPresent("'Online Registration' information has been saved."); | |
6a488035 TO |
251 | } |
252 | ||
4cbe18b8 EM |
253 | /** |
254 | * @param $subject | |
255 | * @param $thankYouMsg | |
256 | * @param $eventTitle | |
257 | */ | |
6a488035 TO |
258 | function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) { |
259 | // Go to Tell A Friend Tab | |
260 | $this->click('link=Tell a Friend'); | |
261 | $this->waitForElementPresent('_qf_Event_cancel-bottom'); | |
262 | ||
263 | // Enable tell a friend feature | |
264 | $this->check('tf_is_active'); | |
265 | $this->waitForElementPresent('tf_thankyou_text'); | |
266 | ||
267 | // Modify the messages | |
268 | $this->type('intro', "This is $subject Test intro text"); | |
269 | $this->type('suggested_message', "$subject Test Message. This is amazing!"); | |
270 | ||
271 | $this->type('tf_thankyou_title', 'Test thank you title'); | |
272 | $this->type('tf_thankyou_text', $thankYouMsg); | |
273 | ||
274 | $this->click('_qf_Event_upload_done-bottom'); | |
673c7418 | 275 | $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']"); |
6a488035 TO |
276 | } |
277 | } | |
278 |