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