Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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 | ||
00be9182 | 38 | public 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 | ||
86bfa4f6 | 78 | $firstName = 'Jane' . substr(sha1(rand()), 0, 7); |
2325644f | 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 | */ | |
00be9182 | 176 | public 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 | */ | |
00be9182 | 204 | public function _testAddLocation($streetAddress) { |
6a488035 TO |
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"); | |
aeaa5f5d | 214 | $this->select('address_1_country_id', 'United States'); |
6a488035 TO |
215 | $this->select("address_1_state_province_id", "value=1004"); |
216 | $this->type("email_1_email", "info@civicrm.org"); | |
217 | ||
218 | $this->click("_qf_Location_upload-bottom"); | |
219 | ||
220 | // Wait for "saved" status msg | |
ed174dea | 221 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
222 | $this->waitForTextPresent("'Event Location' information has been saved."); | |
6a488035 TO |
223 | } |
224 | ||
4cbe18b8 EM |
225 | /** |
226 | * @param $registerIntro | |
227 | * @param bool $multipleRegistrations | |
228 | */ | |
00be9182 | 229 | public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) { |
6a488035 TO |
230 | // Go to Online Registration tab |
231 | $this->click("link=Online Registration"); | |
232 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
233 | ||
234 | $this->check("is_online_registration"); | |
235 | $this->assertChecked("is_online_registration"); | |
236 | if ($multipleRegistrations) { | |
237 | $this->check("is_multiple_registrations"); | |
238 | $this->assertChecked("is_multiple_registrations"); | |
239 | } | |
240 | ||
60709d21 | 241 | $this->click('intro_text-plain'); |
6a488035 TO |
242 | $this->fillRichTextField("intro_text", $registerIntro); |
243 | ||
244 | // enable confirmation email | |
245 | $this->click('xpath=//fieldset[@id="mail"]/div/table/tbody/tr/td[2]/label[contains(text(), "Yes")]'); | |
246 | $this->type("confirm_from_name", "Jane Doe"); | |
247 | $this->type("confirm_from_email", "jane.doe@example.org"); | |
248 | ||
249 | $this->click("_qf_Registration_upload-bottom"); | |
ed174dea | 250 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
251 | $this->waitForTextPresent("'Online Registration' information has been saved."); | |
6a488035 TO |
252 | } |
253 | ||
4cbe18b8 EM |
254 | /** |
255 | * @param $subject | |
256 | * @param $thankYouMsg | |
257 | * @param $eventTitle | |
258 | */ | |
00be9182 | 259 | public function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) { |
6a488035 TO |
260 | // Go to Tell A Friend Tab |
261 | $this->click('link=Tell a Friend'); | |
262 | $this->waitForElementPresent('_qf_Event_cancel-bottom'); | |
263 | ||
264 | // Enable tell a friend feature | |
265 | $this->check('tf_is_active'); | |
266 | $this->waitForElementPresent('tf_thankyou_text'); | |
267 | ||
268 | // Modify the messages | |
269 | $this->type('intro', "This is $subject Test intro text"); | |
270 | $this->type('suggested_message', "$subject Test Message. This is amazing!"); | |
271 | ||
272 | $this->type('tf_thankyou_title', 'Test thank you title'); | |
273 | $this->type('tf_thankyou_text', $thankYouMsg); | |
274 | ||
275 | $this->click('_qf_Event_upload_done-bottom'); | |
673c7418 | 276 | $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@id='option11_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']"); |
6a488035 TO |
277 | } |
278 | } |