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