3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Event_TellAFriendTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testAddEvent() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin('admin');
38 $this->openCiviPage("event/add", "reset=1&action=add");
40 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
41 $eventDescription = "Here is a description for this conference.";
42 $this->_testAddEventInfo($eventTitle, $eventDescription);
44 $streetAddress = "100 Main Street";
45 $this->_testAddLocation($streetAddress);
47 // intro text for registration page
48 $registerIntro = "Fill in all the fields below and click Continue.";
49 $multipleRegistrations = TRUE;
50 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
52 // enable tell a friend
53 $subject = "$eventTitle Tell A Friend";
54 $thankYouMsg = "$eventTitle Tell A Friend Test Thankyou Message";
55 $this->_testAddTellAFriend($subject, $thankYouMsg, $eventTitle);
57 // get the url for registration
58 $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");
59 $this->click("link=$eventTitle");
60 $this->waitForElementPresent("link=Register Now");
61 $this->click("link=Register Now");
62 $this->waitForElementPresent("_qf_Register_upload-bottom");
63 $registerUrl = $this->getLocation();
65 // give permissions for event registration
66 $permission = array('edit-1-register-for-events');
67 $this->changePermissions($permission);
69 // register as an anonymous user
70 $this->webtestLogout();
71 $this->open($registerUrl);
72 $this->waitForElementPresent('_qf_Register_upload-bottom');
74 $firstName = 'Jane' .substr(sha1(rand()), 0, 7);
75 $lastName = 'Doe' . substr(sha1(rand()), 0, 7);
76 $this->type('first_name', "$firstName");
77 $this->type('last_name', "$lastName");
78 $this->type('email-Primary', "$firstName@$lastName.com");
79 $this->click('_qf_Register_upload-bottom');
80 $this->waitForPageToLoad($this->getTimeoutMsec());
81 $this->click("css=div.crm-event-thankyou-form-block div#tell-a-friend a");
82 $this->waitForElementPresent('_qf_Form_cancel');
84 $this->type('suggested_message', '$subject Test Message for the recipients');
86 // fill the recipients
87 $firstName1 = 'John' . substr(sha1(rand()), 0, 7);
88 $lastName1 = substr(sha1(rand()), 0, 7);
89 $this->type('friend_1_first_name', "$firstName1");
90 $this->type('friend_1_last_name', "$lastName1");
91 $this->type('friend_1_email', "$firstName1@$lastName1.com");
93 $firstName2 = 'Smith' . substr(sha1(rand()), 0, 7);
94 $lastName2 = substr(sha1(rand()), 0, 7);
95 $this->type('friend_2_first_name', "$firstName2");
96 $this->type('friend_2_last_name', "$lastName2");
97 $this->type('friend_2_email', "$firstName2@$lastName2.com");
99 $firstName3 = 'James' . substr(sha1(rand()), 0, 7);
100 $lastName3 = substr(sha1(rand()), 0, 7);
101 $this->type('friend_3_first_name', "$firstName3");
102 $this->type('friend_3_last_name', "$lastName3");
103 $this->type('friend_3_email', "$firstName3@$lastName3.com");
105 $this->click('_qf_Form_submit');
106 $this->waitForPageToLoad($this->getTimeoutMsec());
108 $this->waitForTextPresent($thankYouMsg);
110 // Log in using webtestLogin() method
111 $this->webtestLogin();
113 // get all friends contact id
114 $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
115 $this->type('sort_name', $firstName1);
116 $this->click('_qf_Basic_refresh ');
117 $this->waitForPageToLoad($this->getTimeoutMsec());
118 $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
121 $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
122 $this->type('sort_name', $firstName2);
123 $this->click('_qf_Basic_refresh ');
124 $this->waitForPageToLoad($this->getTimeoutMsec());
125 $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
126 $this->waitForPageToLoad($this->getTimeoutMsec());
128 $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
129 $this->type('sort_name', $firstName3);
130 $this->click('_qf_Basic_refresh ');
131 $this->waitForPageToLoad($this->getTimeoutMsec());
132 $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']");
133 $this->waitForPageToLoad($this->getTimeoutMsec());
135 $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh');
136 $this->type('sort_name', $firstName);
137 $this->click('_qf_Basic_refresh ');
138 $this->waitForElementPresent('Print');
139 $this->assertTrue($this->isTextPresent('1 Contact'));
141 // Verify Activity created
142 $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh');
143 $this->type('sort_name', $firstName1);
144 $this->click('_qf_Search_refresh');
145 $this->waitForElementPresent("_qf_Search_next_print");
146 $this->click("xpath=//div[@class='crm-search-results']//table[@class='selector']/tbody/tr[2]/td[9]/span/a[text()='View']");
147 $this->waitForElementPresent('_qf_Activity_cancel-bottom');
149 $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[1]/td[2]",
150 preg_quote("$lastName, $firstName")
153 $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[1]",
154 preg_quote("$lastName1, $firstName1")
156 $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[2]",
157 preg_quote("$lastName2, $firstName2")
159 $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[2]/td[2]/a[3]",
160 preg_quote("$lastName3, $firstName3")
163 $this->verifyText("xpath=//table[@class='crm-info-panel']/tbody/tr[4]/td[2]",
164 preg_quote("Tell a Friend:")
168 function _testAddEventInfo($eventTitle, $eventDescription) {
169 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
171 $this->select("event_type_id", "value=1");
173 // Attendee role s/b selected now.
174 $this->select("default_role_id", "value=1");
176 // Enter Event Title, Summary and Description
177 $this->type("title", $eventTitle);
178 $this->type("summary", "This is a great conference. Sign up now!");
180 // Type description in ckEditor (fieldname, text to type, editor)
181 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
183 // Choose Start and End dates.
184 // Using helper webtestFillDate function.
185 $this->webtestFillDateTime("start_date", "+1 week");
186 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
188 $this->type("max_participants", "50");
189 $this->click("is_map");
190 $this->click("_qf_EventInfo_upload-bottom");
193 function _testAddLocation($streetAddress) {
194 // Wait for Location tab form to load
195 $this->waitForPageToLoad($this->getTimeoutMsec());
196 $this->waitForElementPresent("_qf_Location_upload-bottom");
198 // Fill in address fields
199 $streetAddress = "100 Main Street";
200 $this->type("address_1_street_address", $streetAddress);
201 $this->type("address_1_city", "San Francisco");
202 $this->type("address_1_postal_code", "94117");
203 $this->select("address_1_state_province_id", "value=1004");
204 $this->type("email_1_email", "info@civicrm.org");
206 $this->click("_qf_Location_upload-bottom");
208 // Wait for "saved" status msg
209 $this->waitForPageToLoad($this->getTimeoutMsec());
210 $this->waitForTextPresent("'Location' information has been saved.");
213 function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
214 // Go to Online Registration tab
215 $this->click("link=Online Registration");
216 $this->waitForElementPresent("_qf_Registration_upload-bottom");
218 $this->check("is_online_registration");
219 $this->assertChecked("is_online_registration");
220 if ($multipleRegistrations) {
221 $this->check("is_multiple_registrations");
222 $this->assertChecked("is_multiple_registrations");
225 $this->fillRichTextField("intro_text", $registerIntro);
227 // enable confirmation email
228 $this->click('xpath=//fieldset[@id="mail"]/div/table/tbody/tr/td[2]/label[contains(text(), "Yes")]');
229 $this->type("confirm_from_name", "Jane Doe");
230 $this->type("confirm_from_email", "jane.doe@example.org");
232 $this->click("_qf_Registration_upload-bottom");
233 $this->waitForPageToLoad($this->getTimeoutMsec());
234 $this->waitForTextPresent("'Registration' information has been saved.");
237 function _testAddTellAFriend($subject, $thankYouMsg, $eventTitle) {
238 // Go to Tell A Friend Tab
239 $this->click('link=Tell a Friend');
240 $this->waitForElementPresent('_qf_Event_cancel-bottom');
242 // Enable tell a friend feature
243 $this->check('tf_is_active');
244 $this->waitForElementPresent('tf_thankyou_text');
246 // Modify the messages
247 $this->type('intro', "This is $subject Test intro text");
248 $this->type('suggested_message', "$subject Test Message. This is amazing!");
250 $this->type('tf_thankyou_title', 'Test thank you title');
251 $this->type('tf_thankyou_text', $thankYouMsg);
253 $this->click('_qf_Event_upload_done-bottom');
254 $this->waitForElementPresent("xpath=//div[@id='event_status_id']//div[@class='dataTables_wrapper']/table/tbody//tr/td[1]/a[text()='$eventTitle']");