fixed timeouts WebTest_Profile_BatchUpdateTest
[civicrm-core.git] / tests / phpunit / WebTest / Profile / BatchUpdateTest.php
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testBatchUpdateWithContactSubtypes() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
37
38 // Add new individual using Quick Add block on the main page
39 $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
40 $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7);
41 $Name1 = $lastName1 . ', ' . $firstName1;
42 $this->webtestAddContact($firstName1, $lastName1, "$firstName1.$lastName1@example.com");
43 $this->waitForPageToLoad($this->getTimeoutMsec());
44
45 // Add new individual using Quick Add block on the main page
46 $firstName2 = "James_" . substr(sha1(rand()), 0, 7);
47 $lastName2 = "Smiths_x" . substr(sha1(rand()), 0, 7);
48 $Name2 = $lastName2 . ', ' . $firstName2;
49
50 $firstName3 = "James_" . substr(sha1(rand()), 0, 7);
51 $lastName3 = "Smiths_x" . substr(sha1(rand()), 0, 7);
52 $Name3 = $lastName3 . ', ' . $firstName3;
53
54 $this->webtestAddContact($firstName2, $lastName2, "$firstName2.$lastName2@example.com", "Student");
55 $this->waitForPageToLoad($this->getTimeoutMsec());
56 $this->webtestAddContact($firstName3, $lastName3, "$firstName3.$lastName3@example.com", "Staff");
57 $this->waitForPageToLoad($this->getTimeoutMsec());
58
59 $profileTitle = 'Batch Profile test_' . substr(sha1(rand()), 0, 7);
60 $profileFields = array(
61 array(
62 'type' => 'Individual',
63 'name' => 'Last Name',
64 'label' => 'Last Name'
65 )
66 );
67 $this->addProfile($profileTitle, $profileFields);
68 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
69 $this->type('sort_name', "Smiths_x");
70 $this->click('_qf_Basic_refresh');
71 $this->waitForElementPresent('_qf_Basic_next_print');
72
73 // Batch Update Via Profile
74 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
75 $this->click('CIVICRM_QFID_ts_all_4');
76
77 $this->select('task', "label=Batch Update via Profile");
78 $this->click('Go');
79 $this->waitForElementPresent('_qf_PickProfile_next');
80 $this->waitForElementPresent('uf_group_id');
81 $this->select('uf_group_id', "label={$profileTitle}");
82 $this->click('_qf_PickProfile_next');
83
84 $this->waitForElementPresent('_qf_Batch_next');
85
86 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
87 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
88 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name3}']");
89 // selecting first check of profile
90 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/input");
91
92 $this->waitForElementPresent('_qf_Batch_next');
93 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img");
94 // Because it tends to cause problems, all uses of sleep() must be justified in comments
95 // Sleep should never be used for wait for anything to load from the server
96 // Justification for this instance: FIXME
97 sleep(5);
98 //$this->waitForPageToLoad($this->getTimeoutMsec());
99 $this->waitForElementPresent('_qf_Batch_next');
100 $this->click('_qf_Batch_next');
101 $this->waitForElementPresent('_qf_Result_done');
102 $this->click('_qf_Result_done');
103
104 // Find contact and assert for contact sub type
105 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
106 $this->type('sort_name', $firstName2);
107 $this->click('_qf_Basic_refresh');
108 $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
109 $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
110 $this->waitForPageToLoad($this->getTimeoutMsec());
111
112 $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']";
113 $this->verifyText($xpath, preg_quote("Student"));
114
115 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
116 $this->type('sort_name', $firstName3);
117 $this->click('_qf_Basic_refresh');
118 $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
119 $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
120 $this->waitForPageToLoad($this->getTimeoutMsec());
121
122 $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']";
123 $this->verifyText($xpath, preg_quote("Staff"));
124 }
125
126 function testBatchUpdate() {
127 // Log in using webtestLogin() method
128 $this->webtestLogin();
129
130 // Add new individual using Quick Add block on the main page
131 $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
132 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
133 $Name1 = $lastName . ', ' . $firstName1;
134 $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
135 $this->waitForPageToLoad($this->getTimeoutMsec());
136
137 // Add new individual using Quick Add block on the main page
138 $firstName1 = "James_" . substr(sha1(rand()), 0, 7);
139 $Name2 = $lastName . ', ' . $firstName1;
140 $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
141 $this->waitForPageToLoad($this->getTimeoutMsec());
142 $profileTitle = 'Batch Profile test for contacts ' . substr(sha1(rand()), 0, 7);
143 $profileFor = 'Contacts';
144 $customDataArr = $this->_addCustomData($profileFor);
145 $this->_addProfile($profileTitle, $customDataArr, $profileFor);
146
147 //setting ckeditor as WYSIWYG
148 $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
149 $this->select('editor_id', 'CKEditor');
150 $this->click('_qf_Display_next-bottom');
151 $this->waitForPageToLoad($this->getTimeoutMsec());
152
153 // Find Contact
154 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
155 $this->type('sort_name', $lastName);
156 $this->click('_qf_Basic_refresh');
157 $this->waitForElementPresent('_qf_Basic_next_print');
158
159 // Batch Update Via Profile
160 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
161 $this->click('CIVICRM_QFID_ts_all_4');
162
163 $this->select('task', "label=Batch Update via Profile");
164 $this->click('Go');
165 $this->waitForElementPresent('_qf_PickProfile_next');
166
167 $this->select('uf_group_id', "label={$profileTitle}");
168 $this->click('_qf_PickProfile_next');
169
170 $this->waitForElementPresent('_qf_Batch_next');
171
172 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
173 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
174
175 // selecting first check of profile
176 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/table/tbody/tr/td/input[2]");
177
178 // selecting second check of profile
179 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]");
180 // clicking copy values to rows of first check and verifying
181 // if other check Profile Field check box are affected
182
183 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img");
184 // Because it tends to cause problems, all uses of sleep() must be justified in comments
185 // Sleep should never be used for wait for anything to load from the server
186 // Justification for this instance: FIXME
187 sleep(5);
188 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") &&
189 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") &&
190 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[6]") &&
191 //verification for second field first row
192 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[2]") &&
193 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[4]") &&
194 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[6]") &&
195 //verification for first field second row
196 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td/input[2]") &&
197 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/input[2]") &&
198 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/input[2]")
199 ) {
200 $assertCheck = TRUE;
201 }
202 else {
203 $assertCheck = FALSE;
204 }
205
206 $this->assertTrue($assertCheck, 'copy rows for field one failed');
207
208 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[3]/img");
209 // Because it tends to cause problems, all uses of sleep() must be justified in comments
210 // Sleep should never be used for wait for anything to load from the server
211 // Justification for this instance: FIXME
212 sleep(5);
213 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") &&
214 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") &&
215 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[6]") &&
216 //verification for second field first row
217 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[2]") &&
218 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[4]") &&
219 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[6]") &&
220 //verification for first field second row
221 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td/input[2]") &&
222 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/input[2]") &&
223 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/input[2]")
224 ) {
225 $assertCheck = TRUE;
226 }
227 else {
228 $assertCheck = FALSE;
229 }
230
231 $this->assertTrue($assertCheck, 'copy rows for field two failed');
232
233 $dateElementIdFirstRow = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[4]/input/@id");
234 $dateElementIdSecondRow = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[4]/input/@id");
235
236 $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
237 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[4]/img");
238 // Because it tends to cause problems, all uses of sleep() must be justified in comments
239 // Sleep should never be used for wait for anything to load from the server
240 // Justification for this instance: FIXME
241 sleep(5);
242
243 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) {
244 $assertCheck = TRUE;
245 }
246 else {
247 $assertCheck = FALSE;
248 }
249
250 $this->assertTrue($assertCheck, 'date / time coping failed');
251
252 $richTextAreaIdOne = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[5]/textarea/@id");
253 $richTextAreaIdTwo = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[5]/textarea/@id");
254
255 $this->fillRichTextField($richTextAreaIdOne, 'This is Test Introductory Message', 'CKEditor');
256 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[5]/img");
257 // Because it tends to cause problems, all uses of sleep() must be justified in comments
258 // Sleep should never be used for wait for anything to load from the server
259 // Justification for this instance: FIXME
260 sleep(5);
261
262 if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
263 $assertCheck = TRUE;
264 }
265 else {
266 $assertCheck = FALSE;
267 }
268
269 $this->assertTrue($assertCheck, 'Rich Text Area coping failed');
270
271 // selecting first check of profile
272 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[6]/input");
273 // selecting second check of profile
274 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input");
275 // clicking copy values to rows of first check and verifying
276 // if other radio Profile Field radio buttons are affected
277
278 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[6]/img");
279 // Because it tends to cause problems, all uses of sleep() must be justified in comments
280 // Sleep should never be used for wait for anything to load from the server
281 // Justification for this instance: FIXME
282 sleep(5);
283 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") &&
284 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") &&
285 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[3]") &&
286 //verification for second field first row
287 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input") &&
288 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[2]") &&
289 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[3]") &&
290 //verification for first field second row
291 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input") &&
292 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[2]") &&
293 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[3]")
294 ) {
295 $assertCheck = TRUE;
296 }
297 else {
298 $assertCheck = FALSE;
299 }
300
301 $this->assertTrue($assertCheck, 'copy rows for field one failed[radio button]');
302
303 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[7]/img");
304 // Because it tends to cause problems, all uses of sleep() must be justified in comments
305 // Sleep should never be used for wait for anything to load from the server
306 // Justification for this instance: FIXME
307 sleep(5);
308 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") &&
309 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") &&
310 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[3]") &&
311 //verification for second field first row
312 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input") &&
313 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[2]") &&
314 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[3]") &&
315 //verification for first field second row
316 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input") &&
317 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[2]") &&
318 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[3]")
319 ) {
320 $assertCheck = TRUE;
321 }
322 else {
323 $assertCheck = FALSE;
324 }
325
326 $this->assertTrue($assertCheck, 'copy rows for field two failed[radio button]');
327
328 //test with tinymce editor
329 $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
330 $this->select('editor_id', 'TinyMCE');
331 $this->click('_qf_Display_next-bottom');
332 $this->waitForPageToLoad($this->getTimeoutMsec());
333
334 // Find Contact
335 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
336 $this->type('sort_name', $lastName);
337 $this->click('_qf_Basic_refresh');
338 $this->waitForElementPresent('_qf_Basic_next_print');
339
340 // Batch Update Via Profile
341 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
342 $this->click('CIVICRM_QFID_ts_all_4');
343
344 $this->select('task', "label=Batch Update via Profile");
345 $this->click('Go');
346 $this->waitForElementPresent('_qf_PickProfile_next');
347
348 $this->select('uf_group_id', "label={$profileTitle}");
349 $this->click('_qf_PickProfile_next');
350
351 $this->waitForElementPresent('_qf_Batch_next');
352
353 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
354 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
355
356 $richTextAreaIdOne = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[5]/textarea/@id");
357 $richTextAreaIdTwo = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[5]/textarea/@id");
358
359 $this->selectFrame("css=td.mceIframeContainer iframe#{$richTextAreaIdOne}_ifr");
360 $this->type("//html/body", 'this is intro text');
361 $this->selectFrame('relative=top');
362
363 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[5]/img");
364 // Because it tends to cause problems, all uses of sleep() must be justified in comments
365 // Sleep should never be used for wait for anything to load from the server
366 // Justification for this instance: FIXME
367 sleep(5);
368
369 if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
370 $assertCheck = TRUE;
371 }
372 else {
373 $assertCheck = FALSE;
374 }
375
376 $this->assertTrue($assertCheck, 'Rich Text Area coping failed [TinyMCE]');
377
378 //campaign test for interview
379 //enable CiviCampaign module if necessary
380 $this->enableComponents("CiviCampaign");
381
382 //Adding a survey
383 $this->openCiviPage('survey/add', 'reset=1', '_qf_Main_upload-bottom');
384 $surveyTitle = "BatchUpdateTest Survey" . substr(sha1(rand()), 0, 7);
385 $this->type("title", $surveyTitle);
386 $this->select('activity_type_id', 'label=Survey');
387 $this->click('_qf_Main_upload-bottom');
388 $this->waitForElementPresent('_qf_Questions_cancel-bottom');
389 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label={$profileTitle}");
390 $this->click('_qf_Questions_upload_next-bottom');
391 $this->waitForElementPresent('_qf_Results_cancel-bottom');
392 $this->click('CIVICRM_QFID_1_option_type');
393 $this->type('option_label_1', 'option1');
394 $this->type('option_value_1', 'option1');
395 $this->type('option_label_2', 'option2');
396 $this->type('option_value_2', 'option2');
397 $this->click('_qf_Results_upload_done-bottom');
398 $this->waitForPageToLoad($this->getTimeoutMsec());
399
400 //Reserve and interview respondents
401 $this->openCiviPage('campaign', 'reset=1&subPage=survey');
402 $this->waitForElementPresent("xpath=//table[@id='surveys']/tbody//tr/td[2]/a[text()='{$surveyTitle}']/../following-sibling::td[@class='crm-campaign-voterLinks']/span/ul/li/a");
403 $this->click("xpath=//table[@id='surveys']/tbody//tr/td[2]/a[text()='{$surveyTitle}']/../following-sibling::td[@class='crm-campaign-voterLinks']/span/ul/li/a");
404 $this->waitForPageToLoad($this->getTimeoutMsec());
405 $this->click("xpath=//div[@id='search_form_reserve']/div");
406 $this->waitForElementPresent('sort_name');
407 $this->type('sort_name', $lastName);
408 $this->waitForElementPresent('_qf_Search_refresh');
409 $this->clickLink('_qf_Search_refresh', 'Go');
410 $this->click('toggleSelect');
411 $this->click('Go');
412 $this->waitForElementPresent('_qf_Reserve_next_reserveToInterview-top');
413 $this->clickLink('_qf_Reserve_next_reserveToInterview-top', '_qf_Interview_cancel_interview');
414
415 $this->isElementPresent("xpath=//table[@id='voterRecords']/tbody//tr/td[text()='{$Name2}']");
416 $this->isElementPresent("xpath=//table[@id='voterRecords']/tbody//tr/td[text()='{$Name1}']");
417
418 //edition to be done here
419 // selecting first check of profile
420 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[3]/input[2]");
421 // selecting second check of profile
422 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]");
423 // clicking copy values to rows of first check and verifying
424 // if other check Profile Field check box are affected
425
426 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[3]/div/img");
427 // Because it tends to cause problems, all uses of sleep() must be justified in comments
428 // Sleep should never be used for wait for anything to load from the server
429 // Justification for this instance: FIXME
430 sleep(5);
431 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]") &&
432 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[4]") &&
433 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[6]") &&
434 //verification for second field first row
435 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[2]") &&
436 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[4]") &&
437 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[6]") &&
438 //verification for first field second row
439 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[2]") &&
440 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[4]") &&
441 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[6]")
442 ) {
443 $assertCheck = TRUE;
444 }
445 else {
446 $assertCheck = FALSE;
447 }
448
449 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)');
450
451 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[4]/div/img");
452 // Because it tends to cause problems, all uses of sleep() must be justified in comments
453 // Sleep should never be used for wait for anything to load from the server
454 // Justification for this instance: FIXME
455 sleep(5);
456 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]") &&
457 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[4]") &&
458 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[6]") &&
459 //verification for second field first row
460 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[2]") &&
461 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[4]") &&
462 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[6]") &&
463 //verification for first field second row
464 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[2]") &&
465 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[4]") &&
466 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[6]")
467 ) {
468 $assertCheck = TRUE;
469 }
470 else {
471 $assertCheck = FALSE;
472 }
473
474 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)');
475
476 $dateElementIdFirstRow = $this->getAttribute("xpath=//table[@id='voterRecords']/tbody/tr/td[5]/input/@id");
477 $dateElementIdSecondRow = $this->getAttribute("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[5]/input/@id");
478
479 $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
480 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[5]/div/img");
481 // Because it tends to cause problems, all uses of sleep() must be justified in comments
482 // Sleep should never be used for wait for anything to load from the server
483 // Justification for this instance: FIXME
484 sleep(5);
485
486 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) {
487 $assertCheck = TRUE;
488 }
489 else {
490 $assertCheck = FALSE;
491 }
492
493 $this->assertTrue($assertCheck, 'date / time coping failed for inteview (campaign)');
494
495 $this->type("xpath=//table[@id='voterRecords']/tbody/tr/td[@class='note']/input", 'This is Test Introductory Message');
496 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[8]/div/img");
497 // Because it tends to cause problems, all uses of sleep() must be justified in comments
498 // Sleep should never be used for wait for anything to load from the server
499 // Justification for this instance: FIXME
500 sleep(5);
501
502 if ($this->getValue("xpath=//table[@id='voterRecords']/tbody/tr/td[@class='note']/input") == $this->getValue("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[@class='note']/input")) {
503 $assertCheck = TRUE;
504 }
505 else {
506 $assertCheck = FALSE;
507 }
508
509 $this->assertTrue($assertCheck, 'Note Custom field coping failed');
510
511 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[6]/input");
512 // selecting second check of profile
513 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input");
514 // clicking copy values to rows of first check and verifying
515 // if other radio Profile Field radio buttons are affected
516
517 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[6]/div/img");
518 // Because it tends to cause problems, all uses of sleep() must be justified in comments
519 // Sleep should never be used for wait for anything to load from the server
520 // Justification for this instance: FIXME
521 sleep(5);
522 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input") &&
523 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[2]") &&
524 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[3]") &&
525 //verification for second field first row
526 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input") &&
527 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[2]") &&
528 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[3]") &&
529 //verification for first field second row
530 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input") &&
531 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[2]") &&
532 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[3]")
533 ) {
534 $assertCheck = TRUE;
535 }
536 else {
537 $assertCheck = FALSE;
538 }
539
540 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]');
541
542 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[7]/div/img");
543 // Because it tends to cause problems, all uses of sleep() must be justified in comments
544 // Sleep should never be used for wait for anything to load from the server
545 // Justification for this instance: FIXME
546 sleep(5);
547 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input") &&
548 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[2]") &&
549 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[3]") &&
550 //verification for second field first row
551 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input") &&
552 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[2]") &&
553 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[3]") &&
554 //verification for first field second row
555 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input") &&
556 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[2]") &&
557 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[3]")
558 ) {
559 $assertCheck = TRUE;
560 }
561 else {
562 $assertCheck = FALSE;
563 }
564
565 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)[radio button]');
566
567 //change the editor back to ckeditor
568 $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
569 $this->select('editor_id', 'CKEditor');
570 $this->click('_qf_Display_next-bottom');
571 $this->waitForPageToLoad($this->getTimeoutMsec());
572 }
573
574 function _addProfile($profileTitle, $customDataArr, $profileFor) {
575
576 $this->openCiviPage('admin/uf/group', 'reset=1');
577
578 $this->click('link=Add Profile');
579
580 // Add membership custom data field to profile
581 $this->waitForElementPresent('_qf_Group_cancel-bottom');
582 $this->type('title', $profileTitle);
583 $this->click('_qf_Group_next-bottom');
584
585 $this->waitForElementPresent('_qf_Field_cancel-bottom');
586 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
587
588 foreach ($customDataArr as $key => $customDataParams) {
589 $this->select('field_name[0]', "label={$profileFor}");
590 $this->select('field_name[1]', "label={$customDataParams[1]} :: {$customDataParams[0]}");
591 $this->click('field_name[1]');
592 $this->click('label');
593
594 // Clicking save and new
595 $this->click('_qf_Field_next_new-bottom');
596 $this->waitForPageToLoad($this->getTimeoutMsec());
597 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[1]}' has been saved to '{$profileTitle}'.");
598 }
599 }
600
601 function _addCustomData($profileFor) {
602 $returnArray = array();
603 $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
604
605 $this->openCiviPage('admin/custom/group', 'reset=1');
606
607 //add new custom data
608 $this->click("//a[@id='newCustomDataGroup']/span");
609 $this->waitForPageToLoad($this->getTimeoutMsec());
610
611 //fill custom group title
612 $this->click("title");
613 $this->type("title", $customGroupTitle);
614
615 //custom group extends
616 $this->click("extends[0]");
617 $this->select("extends[0]", "label={$profileFor}");
618 if ($this->isElementPresent('//option')) {
619 $this->click("//option[@value='']");
620 }
621
622 $this->click('_qf_Group_next-bottom');
623 $this->waitForElementPresent('_qf_Field_cancel-bottom');
624
625 //Is custom group created?
626 $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
627
628 //for checkbox 1
629 $checkLabel1 = 'Custom Check One Text_' . substr(sha1(rand()), 0, 4);
630 $this->type('label', $checkLabel1);
631 $this->click('data_type[0]');
632 $this->select('data_type[0]', "label=Alphanumeric");
633 $this->select('data_type[1]', "label=CheckBox");
634
635 // enter checkbox options
636 $checkOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
637 $this->type('option_label_1', $checkOneOptionLabel1);
638 $this->type('option_value_1', 1);
639 $checkOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
640 $this->type('option_label_2', $checkOneOptionLabel2);
641 $this->type('option_value_2', 2);
642 $this->click("link=another choice");
643 $checkOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
644 $this->type('option_label_3', $checkOneOptionLabel3);
645 $this->type('option_value_3', 3);
646
647 //setting options per line to check CRM-9938
648 $this->type("options_per_line", 2);
649
650 //clicking save
651 $this->click('_qf_Field_next');
652 $this->waitForPageToLoad($this->getTimeoutMsec());
653
654 //Is custom field created
655 $this->waitForText('crm-notification-container', "Your custom field '$checkLabel1' has been saved.");
656 $returnArray[1] = array($customGroupTitle, $checkLabel1);
657
658 // create another custom field - Integer Radio
659 $this->click("//a[@id='newCustomField']/span");
660 $this->waitForPageToLoad($this->getTimeoutMsec());
661
662 //for checkbox 2
663 $checkLabel2 = 'Custom Check Two Text_' . substr(sha1(rand()), 0, 4);
664 $this->type('label', $checkLabel2);
665 $this->click('data_type[0]');
666 $this->select('data_type[0]', "label=Alphanumeric");
667 $this->select('data_type[1]', "label=CheckBox");
668
669 // enter checkbox options
670 $checkTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
671 $this->type('option_label_1', $checkTwoOptionLabel1);
672 $this->type('option_value_1', 1);
673 $checkTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
674 $this->type('option_label_2', $checkTwoOptionLabel2);
675 $this->type('option_value_2', 2);
676 $this->click("link=another choice");
677 $checkTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
678 $this->type('option_label_3', $checkTwoOptionLabel3);
679 $this->type('option_value_3', 3);
680
681 //clicking save
682 $this->click('_qf_Field_next');
683 $this->waitForPageToLoad($this->getTimeoutMsec());
684
685 //Is custom field created
686 $this->waitForText('crm-notification-container', "Your custom field '$checkLabel2' has been saved.");
687 $returnArray[2] = array($customGroupTitle, $checkLabel2);
688
689 // create another custom field - Integer Radio
690 $this->click("//a[@id='newCustomField']/span");
691 $this->waitForPageToLoad($this->getTimeoutMsec());
692
693 // create another custom field - Date
694 $dateFieldLabel = 'Custom Date Field' . substr(sha1(rand()), 0, 4);
695 $this->type('label', $dateFieldLabel);
696 $this->click('data_type[0]');
697 $this->select('data_type[0]', "label=Date");
698 $this->waitForElementPresent('start_date_years');
699
700 // enter years prior to current date
701 $this->type('start_date_years', 3);
702
703 // enter years upto the end year
704 $this->type('end_date_years', 3);
705
706 // select the date and time format
707 $this->select('date_format', "value=yy-mm-dd");
708 $this->select('time_format', "value=2");
709
710 //clicking save
711 $this->click('_qf_Field_next');
712 $this->waitForPageToLoad($this->getTimeoutMsec());
713
714 //Is custom field created
715 $this->waitForText('crm-notification-container', "Your custom field '$dateFieldLabel' has been saved.");
716 $returnArray[3] = array($customGroupTitle, $dateFieldLabel);
717
718 // create another custom field - Integer Radio
719 $this->click("//a[@id='newCustomField']/span");
720 $this->waitForPageToLoad($this->getTimeoutMsec());
721
722 //create rich text editor field
723 $richTextField = 'Custom Rich TextField_' . substr(sha1(rand()), 0, 4);
724 $this->type('label', $richTextField);
725 $this->click('data_type[0]');
726 $this->select('data_type[0]', "label=Note");
727 $this->select('data_type[1]', "label=RichTextEditor");
728
729 //clicking save
730 $this->click('_qf_Field_next');
731 $this->waitForPageToLoad($this->getTimeoutMsec());
732
733 //Is custom field created
734 $this->waitForText('crm-notification-container', "Your custom field '$richTextField' has been saved.");
735 $returnArray[4] = array($customGroupTitle, $richTextField);
736
737 // create another custom field - Integer Radio
738 $this->click("//a[@id='newCustomField']/span");
739 $this->waitForPageToLoad($this->getTimeoutMsec());
740
741 //create radio button field
742 //for radio 1
743 $radioLabel1 = 'Custom Radio One Text_' . substr(sha1(rand()), 0, 4);
744 $this->type('label', $radioLabel1);
745 $this->click('data_type[0]');
746 $this->select('data_type[0]', "label=Alphanumeric");
747 $this->select('data_type[1]', "label=Radio");
748
749 // enter radio options
750 $radioOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
751 $this->type('option_label_1', $radioOneOptionLabel1);
752 $this->type('option_value_1', 1);
753 $radioOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
754 $this->type('option_label_2', $radioOneOptionLabel2);
755 $this->type('option_value_2', 2);
756 $this->click("link=another choice");
757 $radioOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
758 $this->type('option_label_3', $radioOneOptionLabel3);
759 $this->type('option_value_3', 3);
760
761 //clicking save
762 $this->click('_qf_Field_next');
763 $this->waitForPageToLoad($this->getTimeoutMsec());
764
765 //Is custom field created
766 $this->assertElementContainsText('crm-container', "Your custom field '$radioLabel1' has been saved.");
767 $returnArray[5] = array($customGroupTitle, $radioLabel1);
768
769 // create another custom field - Integer Radio
770 $this->click("//a[@id='newCustomField']/span");
771 $this->waitForPageToLoad($this->getTimeoutMsec());
772
773 //for radio 2
774 $radioLabel2 = 'Custom Radio Two Text_' . substr(sha1(rand()), 0, 4);
775 $this->type('label', $radioLabel2);
776 $this->click('data_type[0]');
777 $this->select('data_type[0]', "label=Alphanumeric");
778 $this->select('data_type[1]', "label=Radio");
779
780 // enter radio options
781 $radioTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
782 $this->type('option_label_1', $radioTwoOptionLabel1);
783 $this->type('option_value_1', 1);
784 $radioTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
785 $this->type('option_label_2', $radioTwoOptionLabel2);
786 $this->type('option_value_2', 2);
787 $this->click("link=another choice");
788 $radioTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
789 $this->type('option_label_3', $radioTwoOptionLabel3);
790 $this->type('option_value_3', 3);
791
792 //clicking save
793 $this->click('_qf_Field_next');
794 $this->waitForPageToLoad($this->getTimeoutMsec());
795
796 //Is custom field created
797 $this->waitForText('crm-notification-container', "Your custom field '$radioLabel2' has been saved.");
798 $returnArray[6] = array($customGroupTitle, $radioLabel2);
799
800 return $returnArray;
801 }
802 }