3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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';
30 * Class WebTest_Profile_BatchUpdateTest
32 class WebTest_Profile_BatchUpdateTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testBatchUpdateWithContactSubtypes() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
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");
48 // Add new individual using Quick Add block on the main page
49 $firstName2 = "James_" . substr(sha1(rand()), 0, 7);
50 $lastName2 = "Smiths_x" . substr(sha1(rand()), 0, 7);
51 $Name2 = $lastName2 . ', ' . $firstName2;
53 $firstName3 = "James_" . substr(sha1(rand()), 0, 7);
54 $lastName3 = "Smiths_x" . substr(sha1(rand()), 0, 7);
55 $Name3 = $lastName3 . ', ' . $firstName3;
57 $this->webtestAddContact($firstName2, $lastName2, "$firstName2.$lastName2@example.com", "Student");
58 $this->webtestAddContact($firstName3, $lastName3, "$firstName3.$lastName3@example.com", "Staff");
60 $profileTitle = 'Batch Profile test_' . substr(sha1(rand()), 0, 7);
61 $profileFields = array(
63 'type' => 'Individual',
64 'name' => 'Last Name',
65 'label' => 'Last Name',
68 $this->addProfile($profileTitle, $profileFields);
69 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
70 $this->type('sort_name', "Smiths_x");
71 $this->click('_qf_Basic_refresh');
73 // Update multiple contacts
74 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
75 $this->click('CIVICRM_QFID_ts_all_4');
77 $this->select('task', "label=Update multiple contacts");
78 $this->waitForElementPresent('_qf_PickProfile_next');
79 $this->waitForElementPresent('uf_group_id');
80 $this->select('uf_group_id', "label={$profileTitle}");
81 $this->click('_qf_PickProfile_next');
83 $this->waitForElementPresent('_qf_Batch_next');
85 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
86 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
87 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name3}']");
88 // selecting first check of profile
89 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/input");
91 $this->waitForElementPresent('_qf_Batch_next');
92 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img");
93 // Because it tends to cause problems, all uses of sleep() must be justified in comments
94 // Sleep should never be used for wait for anything to load from the server
95 // Justification for this instance: FIXME
97 //$this->waitForPageToLoad($this->getTimeoutMsec());
98 $this->waitForElementPresent('_qf_Batch_next');
99 $this->click('_qf_Batch_next');
100 $this->waitForElementPresent('_qf_Result_done');
101 $this->click('_qf_Result_done');
103 // Find contact and assert for contact sub type
104 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
105 $this->type('sort_name', $firstName2);
106 $this->click('_qf_Basic_refresh');
107 $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
108 $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
109 $this->waitForPageToLoad($this->getTimeoutMsec());
111 $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']";
112 $this->verifyText($xpath, preg_quote("Student"));
114 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
115 $this->type('sort_name', $firstName3);
116 $this->click('_qf_Basic_refresh');
117 $this->waitForElementPresent("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
118 $this->click("xpath=//div[@class='crm-search-results']/table/tbody//td/span/a[text()='View']");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
121 $xpath = "xpath=//div[@id='contact-summary']/div/div[2]/div/div/div[2]/div[@class='crm-content crm-contact_type_label']";
122 $this->verifyText($xpath, preg_quote("Staff"));
125 public function testBatchUpdate() {
126 $this->markTestSkipped('Skipping for now as it works fine locally.');
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");
136 // Add new individual using Quick Add block on the main page
137 $firstName1 = "James_" . substr(sha1(rand()), 0, 7);
138 $Name2 = $lastName . ', ' . $firstName1;
139 $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
140 $profileTitle = 'Batch Profile test for contacts ' . substr(sha1(rand()), 0, 7);
141 $profileFor = 'Contacts';
142 $customDataArr = $this->_addCustomData($profileFor);
143 $this->_addProfile($profileTitle, $customDataArr, $profileFor);
145 //setting ckeditor as WYSIWYG
146 $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
147 $this->select('editor_id', 'CKEditor');
148 $this->click('_qf_Display_next-bottom');
149 $this->waitForPageToLoad($this->getTimeoutMsec());
152 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
153 $this->type('sort_name', $lastName);
154 $this->click('_qf_Basic_refresh');
156 // Update multiple contacts
157 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
158 $this->click('CIVICRM_QFID_ts_all_4');
160 $this->select('task', "label=Update multiple contacts");
161 $this->waitForElementPresent('_qf_PickProfile_next');
163 $this->select('uf_group_id', "label={$profileTitle}");
164 $this->click('_qf_PickProfile_next');
166 $this->waitForElementPresent('_qf_Batch_next');
168 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']");
169 $this->isElementPresent("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']");
171 // selecting first check of profile
172 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/table/tbody/tr/td/input[2]");
174 // selecting second check of profile
175 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]");
176 // clicking copy values to rows of first check and verifying
177 // if other check Profile Field check box are affected
179 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img");
180 // Because it tends to cause problems, all uses of sleep() must be justified in comments
181 // Sleep should never be used for wait for anything to load from the server
182 // Justification for this instance: FIXME
184 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") &&
185 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") &&
186 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[6]") &&
187 //verification for second field first row
188 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[2]") &&
189 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[4]") &&
190 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[6]") &&
191 //verification for first field second row
192 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td/input[2]") &&
193 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/input[2]") &&
194 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/input[2]")
199 $assertCheck = FALSE;
202 $this->assertTrue($assertCheck, 'copy rows for field one failed');
204 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[3]/img");
205 // Because it tends to cause problems, all uses of sleep() must be justified in comments
206 // Sleep should never be used for wait for anything to load from the server
207 // Justification for this instance: FIXME
209 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") &&
210 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") &&
211 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[6]") &&
212 //verification for second field first row
213 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[2]") &&
214 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[4]") &&
215 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[3]/input[6]") &&
216 //verification for first field second row
217 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td/input[2]") &&
218 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr/td[2]/input[2]") &&
219 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/input[2]")
224 $assertCheck = FALSE;
227 $this->assertTrue($assertCheck, 'copy rows for field two failed');
229 $dateElementIdFirstRow = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[4]/input/@id");
230 $dateElementIdSecondRow = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[4]/input/@id");
232 $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
233 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[4]/img");
234 // Because it tends to cause problems, all uses of sleep() must be justified in comments
235 // Sleep should never be used for wait for anything to load from the server
236 // Justification for this instance: FIXME
239 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}") == $this->getValue("{$dateElementIdSecondRow}")) {
243 $assertCheck = FALSE;
246 $this->assertTrue($assertCheck, 'date / time coping failed');
248 $richTextAreaIdOne = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[5]/textarea/@id");
249 $richTextAreaIdTwo = $this->getAttribute("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[5]/textarea/@id");
251 $this->fillRichTextField($richTextAreaIdOne, 'This is Test Introductory Message', 'CKEditor');
252 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[5]/img");
253 // Because it tends to cause problems, all uses of sleep() must be justified in comments
254 // Sleep should never be used for wait for anything to load from the server
255 // Justification for this instance: FIXME
258 if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
262 $assertCheck = FALSE;
265 $this->assertTrue($assertCheck, 'Rich Text Area coping failed');
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
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
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]")
294 $assertCheck = FALSE;
297 $this->assertTrue($assertCheck, 'copy rows for field one failed[radio button]');
299 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[7]/img");
300 // Because it tends to cause problems, all uses of sleep() must be justified in comments
301 // Sleep should never be used for wait for anything to load from the server
302 // Justification for this instance: FIXME
304 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") &&
305 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") &&
306 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[3]") &&
307 //verification for second field first row
308 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input") &&
309 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[2]") &&
310 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[3]") &&
311 //verification for first field second row
312 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input") &&
313 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[2]") &&
314 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[3]")
319 $assertCheck = FALSE;
322 $this->assertTrue($assertCheck, 'copy rows for field two failed[radio button]');
324 //campaign test for interview
325 //enable CiviCampaign module if necessary
326 $this->enableComponents("CiviCampaign");
329 $this->openCiviPage('survey/add', 'reset=1', '_qf_Main_upload-bottom');
330 $surveyTitle = "BatchUpdateTest Survey" . substr(sha1(rand()), 0, 7);
331 $this->type("title", $surveyTitle);
332 $this->select('activity_type_id', 'label=Survey');
333 $this->click('_qf_Main_upload-bottom');
334 $this->waitForElementPresent('_qf_Questions_cancel-bottom');
335 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label={$profileTitle}");
336 $this->click('_qf_Questions_upload_next-bottom');
337 $this->waitForElementPresent('_qf_Results_cancel-bottom');
338 $this->click('CIVICRM_QFID_1_option_type');
339 $this->type('option_label_1', 'option1');
340 $this->type('option_value_1', 'option1');
341 $this->type('option_label_2', 'option2');
342 $this->type('option_value_2', 'option2');
343 $this->click('_qf_Results_upload_done-bottom');
344 $this->waitForPageToLoad($this->getTimeoutMsec());
346 //Reserve and interview respondents
347 $this->openCiviPage('campaign', 'reset=1&subPage=survey');
348 $this->waitForElementPresent("xpath=//table[@class='surveys dataTable no-footer']/tbody//tr/td[2]/div/a[text()='{$surveyTitle}']/../../following-sibling::td[@class=' crm-campaign-voterLinks']/span/ul/li/a");
349 $this->click("xpath=//table[@class='surveys dataTable no-footer']/tbody//tr/td[2]/div/a[text()='{$surveyTitle}']/../../following-sibling::td[@class=' crm-campaign-voterLinks']/span/ul/li/a");
350 $this->waitForPageToLoad($this->getTimeoutMsec());
351 $this->click("xpath=//div[@id='search_form_reserve']/div");
352 $this->waitForElementPresent('sort_name');
353 $this->type('sort_name', $lastName);
354 $this->waitForElementPresent('_qf_Search_refresh');
355 $this->clickLink('_qf_Search_refresh', 'toggleSelect');
356 $this->click('toggleSelect');
357 $this->select('task', "value=2");
358 $this->waitForElementPresent('_qf_Reserve_next_reserveToInterview-top');
359 $this->clickLink('_qf_Reserve_next_reserveToInterview-top', '_qf_Interview_cancel_interview');
361 $this->isElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[2][text()='{$Name2}']");
362 $this->isElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[2][text()='{$Name1}']");
364 //edition to be done here
365 // selecting first check of profile
366 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[3]/input[2]");
367 // selecting second check of profile
368 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[2]");
369 // clicking copy values to rows of first check and verifying
370 // if other check Profile Field check box are affected
372 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[3]/div/img");
373 // Because it tends to cause problems, all uses of sleep() must be justified in comments
374 // Sleep should never be used for wait for anything to load from the server
375 // Justification for this instance: FIXME
377 if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[2]") &&
378 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[4]") &&
379 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[6]") &&
380 //verification for second field first row
381 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[2]") &&
382 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[4]") &&
383 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[6]") &&
384 //verification for first field second row
385 $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[2]") &&
386 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[4]") &&
387 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[6]")
392 $assertCheck = FALSE;
395 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)');
397 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[4]/div/img");
398 // Because it tends to cause problems, all uses of sleep() must be justified in comments
399 // Sleep should never be used for wait for anything to load from the server
400 // Justification for this instance: FIXME
402 if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[2]") &&
403 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[4]") &&
404 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/input[6]") &&
405 //verification for second field first row
406 $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[2]") &&
407 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[4]") &&
408 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[4]/input[6]") &&
409 //verification for first field second row
410 $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[2]") &&
411 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[4]") &&
412 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[3]/input[6]")
417 $assertCheck = FALSE;
420 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)');
422 $dateElementIdFirstRow = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[5]/input/@id");
423 $dateElementIdSecondRow = $this->getAttribute("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[5]/input/@id");
425 $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
426 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[5]/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
432 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}") == $this->getValue("{$dateElementIdSecondRow}")) {
436 $assertCheck = FALSE;
439 $this->assertTrue($assertCheck, 'date / time coping failed for inteview (campaign)');
441 $this->type("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[@class='note']/input", 'This is Test Introductory Message');
442 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[8]/div/img");
443 // Because it tends to cause problems, all uses of sleep() must be justified in comments
444 // Sleep should never be used for wait for anything to load from the server
445 // Justification for this instance: FIXME
448 if ($this->getValue("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[@class='note']/input") == $this->getValue("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[@class='note']/input")) {
452 $assertCheck = FALSE;
455 $this->assertTrue($assertCheck, 'Note Custom field coping failed');
457 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[6]/input");
458 // selecting second check of profile
459 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input");
460 // clicking copy values to rows of first check and verifying
461 // if other radio Profile Field radio buttons are affected
463 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[6]/div/img");
464 // Because it tends to cause problems, all uses of sleep() must be justified in comments
465 // Sleep should never be used for wait for anything to load from the server
466 // Justification for this instance: FIXME
468 if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input") &&
469 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[2]") &&
470 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[3]") &&
471 //verification for second field first row
472 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input") &&
473 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[2]") &&
474 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[3]") &&
475 //verification for first field second row
476 $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input") &&
477 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[2]") &&
478 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[3]")
483 $assertCheck = FALSE;
486 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]');
488 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/thead/tr/th[7]/div/img");
489 // Because it tends to cause problems, all uses of sleep() must be justified in comments
490 // Sleep should never be used for wait for anything to load from the server
491 // Justification for this instance: FIXME
493 if ($this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input") &&
494 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[2]") &&
495 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/input[3]") &&
496 //verification for second field first row
497 $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input") &&
498 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[2]") &&
499 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[7]/input[3]") &&
500 //verification for first field second row
501 $this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input") &&
502 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[2]") &&
503 !$this->isChecked("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr[2]/td[6]/input[3]")
508 $assertCheck = FALSE;
511 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)[radio button]');
512 $this->clickLink("_qf_Interview_cancel_interview");
514 //change the editor back to ckeditor
515 $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
516 $this->select('editor_id', 'CKEditor');
517 $this->click('_qf_Display_next-bottom');
518 $this->waitForPageToLoad($this->getTimeoutMsec());
522 * @param $profileTitle
523 * @param $customDataArr
526 public function _addProfile($profileTitle, $customDataArr, $profileFor) {
528 $this->openCiviPage('admin/uf/group', 'reset=1');
530 $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom');
532 // Add membership custom data field to profile
533 $this->type('title', $profileTitle);
535 // Standalone form or directory
536 $this->click('uf_group_type_Profile');
538 $this->clickLink('_qf_Group_next-bottom');
540 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
542 $this->waitForElementPresent("field_name[0]");
543 foreach ($customDataArr as $customDataParams) {
544 $this->select('field_name[0]', "label={$profileFor}");
545 $this->select('field_name[1]', "label={$customDataParams[1]} :: {$customDataParams[0]}");
546 $this->click('field_name[1]');
547 $this->click('label');
549 // Clicking save and new
550 $this->click('_qf_Field_next_new-bottom');
551 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[1]}' has been saved to '{$profileTitle}'.");
552 $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
561 public function _addCustomData($profileFor) {
562 $returnArray = array();
563 $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
565 $this->openCiviPage('admin/custom/group', 'reset=1');
567 //add new custom data
568 $this->clickLink("//a[@id='newCustomDataGroup']/span");
570 //fill custom group title
571 $this->click("title");
572 $this->type("title", $customGroupTitle);
574 //custom group extends
575 $this->click("extends[0]");
576 $this->select("extends[0]", "label={$profileFor}");
577 if ($this->isElementPresent('//option')) {
578 $this->click("//option[@value='']");
581 $this->clickLink('_qf_Group_next-bottom');
583 //Is custom group created?
584 $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
587 $this->waitForElementPresent("label");
588 $checkLabel1 = 'Custom Check One Text_' . substr(sha1(rand()), 0, 4);
589 $this->waitForAjaxContent();
590 $this->type('label', $checkLabel1);
591 $this->click('data_type[0]');
592 $this->select('data_type[0]', "label=Alphanumeric");
593 $this->select('data_type[1]', "label=CheckBox");
595 // enter checkbox options
596 $checkOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
597 $this->type('option_label_1', $checkOneOptionLabel1);
598 $this->type('option_value_1', 1);
599 $checkOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
600 $this->type('option_label_2', $checkOneOptionLabel2);
601 $this->type('option_value_2', 2);
602 $this->click("link=another choice");
603 $checkOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
604 $this->type('option_label_3', $checkOneOptionLabel3);
605 $this->type('option_value_3', 3);
607 //setting options per line to check CRM-9938
608 $this->type("options_per_line", 2);
611 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
613 //Is custom field created
614 $this->waitForText('crm-notification-container', "Custom field '$checkLabel1' has been saved.");
615 $this->waitForElementPresent("label");
616 $returnArray[1] = array($customGroupTitle, $checkLabel1);
618 // create another custom field - Integer Radio
620 $checkLabel2 = 'Custom Check Two Text_' . substr(sha1(rand()), 0, 4);
621 $this->waitForAjaxContent();
622 $this->type('label', $checkLabel2);
623 $this->click('data_type[0]');
624 $this->select('data_type[0]', "label=Alphanumeric");
625 $this->select('data_type[1]', "label=CheckBox");
627 // enter checkbox options
628 $checkTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
629 $this->type('option_label_1', $checkTwoOptionLabel1);
630 $this->type('option_value_1', 1);
631 $checkTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
632 $this->type('option_label_2', $checkTwoOptionLabel2);
633 $this->type('option_value_2', 2);
634 $this->click("link=another choice");
635 $checkTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
636 $this->type('option_label_3', $checkTwoOptionLabel3);
637 $this->type('option_value_3', 3);
640 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
642 //Is custom field created
643 $this->waitForText('crm-notification-container', "Custom field '$checkLabel2' has been saved.");
644 $returnArray[2] = array($customGroupTitle, $checkLabel2);
646 // create another custom field - Date
647 $this->waitForElementPresent("label");
648 $dateFieldLabel = 'Custom Date Field' . substr(sha1(rand()), 0, 4);
649 $this->waitForAjaxContent();
650 $this->type('label', $dateFieldLabel);
651 $this->click('data_type[0]');
652 $this->select('data_type[0]', "label=Date");
653 $this->waitForElementPresent('start_date_years');
655 // enter years prior to current date
656 $this->type('start_date_years', 3);
658 // enter years up to the end year
659 $this->type('end_date_years', 3);
661 // select the date and time format
662 $this->select('date_format', "value=yy-mm-dd");
663 $this->select('time_format', "value=2");
666 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
667 //Is custom field created
668 $this->waitForText('crm-notification-container', "Custom field '$dateFieldLabel' has been saved.");
669 $returnArray[3] = array($customGroupTitle, $dateFieldLabel);
671 //create rich text editor field
672 $this->waitForElementPresent("label");
673 $richTextField = 'Custom Rich TextField_' . substr(sha1(rand()), 0, 4);
674 $this->waitForAjaxContent();
675 $this->type('label', $richTextField);
676 $this->click('data_type[0]');
677 $this->select('data_type[0]', "label=Note");
678 $this->select('data_type[1]', "value=RichTextEditor");
681 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
683 //Is custom field created
684 $this->waitForText('crm-notification-container', "Custom field '$richTextField' has been saved.");
685 $returnArray[4] = array($customGroupTitle, $richTextField);
687 //create radio button field
689 $this->waitForElementPresent("label");
690 $radioLabel1 = 'Custom Radio One Text_' . substr(sha1(rand()), 0, 4);
691 $this->waitForAjaxContent();
692 $this->type('label', $radioLabel1);
693 $this->click('data_type[0]');
694 $this->select('data_type[0]', "label=Alphanumeric");
695 $this->select('data_type[1]', "label=Radio");
697 // enter radio options
698 $radioOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
699 $this->type('option_label_1', $radioOneOptionLabel1);
700 $this->type('option_value_1', 1);
701 $radioOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
702 $this->type('option_label_2', $radioOneOptionLabel2);
703 $this->type('option_value_2', 2);
704 $this->click("link=another choice");
705 $radioOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
706 $this->type('option_label_3', $radioOneOptionLabel3);
707 $this->type('option_value_3', 3);
710 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
712 //Is custom field created
713 $this->waitForText('crm-notification-container', "Custom field '$radioLabel1' has been saved.");
714 $returnArray[5] = array($customGroupTitle, $radioLabel1);
716 // create another custom field - Alpha Radio
718 $this->waitForElementPresent("label");
719 $radioLabel2 = 'Custom Radio Two Text_' . substr(sha1(rand()), 0, 4);
720 $this->waitForAjaxContent();
721 $this->type('label', $radioLabel2);
722 $this->click('data_type[0]');
723 $this->select('data_type[0]', "label=Alphanumeric");
724 $this->select('data_type[1]', "label=Radio");
726 // enter radio options
727 $radioTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
728 $this->type('option_label_1', $radioTwoOptionLabel1);
729 $this->type('option_value_1', 1);
730 $radioTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
731 $this->type('option_label_2', $radioTwoOptionLabel2);
732 $this->type('option_value_2', 2);
733 $this->click("link=another choice");
734 $radioTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
735 $this->type('option_label_3', $radioTwoOptionLabel3);
736 $this->type('option_value_3', 3);
739 $this->clickLink('_qf_Field_done', 'newCustomField', FALSE);
741 //Is custom field created
742 $this->waitForText('crm-notification-container', "Custom field '$radioLabel2' has been saved.");
743 $returnArray[6] = array($customGroupTitle, $radioLabel2);