3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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_Profile_BatchUpdateTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testBatchUpdateWithContactSubtypes() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
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());
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;
50 $firstName3 = "James_" . substr(sha1(rand()), 0, 7);
51 $lastName3 = "Smiths_x" . substr(sha1(rand()), 0, 7);
52 $Name3 = $lastName3 . ', ' . $firstName3;
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());
59 $profileTitle = 'Batch Profile test_' . substr(sha1(rand()), 0, 7);
60 $profileFields = array(
62 'type' => 'Individual',
63 'name' => 'Last Name',
64 'label' => 'Last Name'
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');
73 // Batch Update Via Profile
74 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
75 $this->click('CIVICRM_QFID_ts_all_4');
77 $this->select('task', "label=Batch Update via Profile");
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');
84 $this->waitForElementPresent('_qf_Batch_next');
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");
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
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');
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());
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"));
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());
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"));
126 function testBatchUpdate() {
127 // Log in using webtestLogin() method
128 $this->webtestLogin();
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());
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);
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());
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');
159 // Batch Update Via Profile
160 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
161 $this->click('CIVICRM_QFID_ts_all_4');
163 $this->select('task', "label=Batch Update via Profile");
165 $this->waitForElementPresent('_qf_PickProfile_next');
167 $this->select('uf_group_id', "label={$profileTitle}");
168 $this->click('_qf_PickProfile_next');
170 $this->waitForElementPresent('_qf_Batch_next');
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}']");
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]");
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
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
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]")
203 $assertCheck = FALSE;
206 $this->assertTrue($assertCheck, 'copy rows for field one failed');
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
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]")
228 $assertCheck = FALSE;
231 $this->assertTrue($assertCheck, 'copy rows for field two failed');
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");
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
243 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) {
247 $assertCheck = FALSE;
250 $this->assertTrue($assertCheck, 'date / time coping failed');
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");
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
262 if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
266 $assertCheck = FALSE;
269 $this->assertTrue($assertCheck, 'Rich Text Area coping failed');
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
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
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]")
298 $assertCheck = FALSE;
301 $this->assertTrue($assertCheck, 'copy rows for field one failed[radio button]');
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
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]")
323 $assertCheck = FALSE;
326 $this->assertTrue($assertCheck, 'copy rows for field two failed[radio button]');
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());
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');
340 // Batch Update Via Profile
341 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
342 $this->click('CIVICRM_QFID_ts_all_4');
344 $this->select('task', "label=Batch Update via Profile");
346 $this->waitForElementPresent('_qf_PickProfile_next');
348 $this->select('uf_group_id', "label={$profileTitle}");
349 $this->click('_qf_PickProfile_next');
351 $this->waitForElementPresent('_qf_Batch_next');
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}']");
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");
359 $this->selectFrame("css=td.mceIframeContainer iframe#{$richTextAreaIdOne}_ifr");
360 $this->type("//html/body", 'this is intro text');
361 $this->selectFrame('relative=top');
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
369 if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
373 $assertCheck = FALSE;
376 $this->assertTrue($assertCheck, 'Rich Text Area coping failed [TinyMCE]');
378 //campaign test for interview
379 //enable CiviCampaign module if necessary
380 $this->enableComponents("CiviCampaign");
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());
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');
412 $this->waitForElementPresent('_qf_Reserve_next_reserveToInterview-top');
413 $this->clickLink('_qf_Reserve_next_reserveToInterview-top', '_qf_Interview_cancel_interview');
415 $this->isElementPresent("xpath=//table[@id='voterRecords']/tbody//tr/td[text()='{$Name2}']");
416 $this->isElementPresent("xpath=//table[@id='voterRecords']/tbody//tr/td[text()='{$Name1}']");
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
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
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]")
446 $assertCheck = FALSE;
449 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)');
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
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]")
471 $assertCheck = FALSE;
474 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)');
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");
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
486 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) {
490 $assertCheck = FALSE;
493 $this->assertTrue($assertCheck, 'date / time coping failed for inteview (campaign)');
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
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")) {
506 $assertCheck = FALSE;
509 $this->assertTrue($assertCheck, 'Note Custom field coping failed');
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
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
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]")
537 $assertCheck = FALSE;
540 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]');
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
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]")
562 $assertCheck = FALSE;
565 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)[radio button]');
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());
574 function _addProfile($profileTitle, $customDataArr, $profileFor) {
576 $this->openCiviPage('admin/uf/group', 'reset=1');
578 $this->click('link=Add Profile');
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');
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.");
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');
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}'.");
601 function _addCustomData($profileFor) {
602 $returnArray = array();
603 $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
605 $this->openCiviPage('admin/custom/group', 'reset=1');
607 //add new custom data
608 $this->click("//a[@id='newCustomDataGroup']/span");
609 $this->waitForPageToLoad($this->getTimeoutMsec());
611 //fill custom group title
612 $this->click("title");
613 $this->type("title", $customGroupTitle);
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='']");
622 $this->click('_qf_Group_next-bottom');
623 $this->waitForElementPresent('_qf_Field_cancel-bottom');
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.");
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");
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);
647 //setting options per line to check CRM-9938
648 $this->type("options_per_line", 2);
651 $this->click('_qf_Field_next');
652 $this->waitForPageToLoad($this->getTimeoutMsec());
654 //Is custom field created
655 $this->waitForText('crm-notification-container', "Your custom field '$checkLabel1' has been saved.");
656 $returnArray[1] = array($customGroupTitle, $checkLabel1);
658 // create another custom field - Integer Radio
659 $this->click("//a[@id='newCustomField']/span");
660 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
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);
682 $this->click('_qf_Field_next');
683 $this->waitForPageToLoad($this->getTimeoutMsec());
685 //Is custom field created
686 $this->waitForText('crm-notification-container', "Your custom field '$checkLabel2' has been saved.");
687 $returnArray[2] = array($customGroupTitle, $checkLabel2);
689 // create another custom field - Integer Radio
690 $this->click("//a[@id='newCustomField']/span");
691 $this->waitForPageToLoad($this->getTimeoutMsec());
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');
700 // enter years prior to current date
701 $this->type('start_date_years', 3);
703 // enter years upto the end year
704 $this->type('end_date_years', 3);
706 // select the date and time format
707 $this->select('date_format', "value=yy-mm-dd");
708 $this->select('time_format', "value=2");
711 $this->click('_qf_Field_next');
712 $this->waitForPageToLoad($this->getTimeoutMsec());
714 //Is custom field created
715 $this->waitForText('crm-notification-container', "Your custom field '$dateFieldLabel' has been saved.");
716 $returnArray[3] = array($customGroupTitle, $dateFieldLabel);
718 // create another custom field - Integer Radio
719 $this->click("//a[@id='newCustomField']/span");
720 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
730 $this->click('_qf_Field_next');
731 $this->waitForPageToLoad($this->getTimeoutMsec());
733 //Is custom field created
734 $this->waitForText('crm-notification-container', "Your custom field '$richTextField' has been saved.");
735 $returnArray[4] = array($customGroupTitle, $richTextField);
737 // create another custom field - Integer Radio
738 $this->click("//a[@id='newCustomField']/span");
739 $this->waitForPageToLoad($this->getTimeoutMsec());
741 //create radio button field
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");
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);
762 $this->click('_qf_Field_next');
763 $this->waitForPageToLoad($this->getTimeoutMsec());
765 //Is custom field created
766 $this->assertElementContainsText('crm-container', "Your custom field '$radioLabel1' has been saved.");
767 $returnArray[5] = array($customGroupTitle, $radioLabel1);
769 // create another custom field - Integer Radio
770 $this->click("//a[@id='newCustomField']/span");
771 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
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);
793 $this->click('_qf_Field_next');
794 $this->waitForPageToLoad($this->getTimeoutMsec());
796 //Is custom field created
797 $this->waitForText('crm-notification-container', "Your custom field '$radioLabel2' has been saved.");
798 $returnArray[6] = array($customGroupTitle, $radioLabel2);