Merge pull request #11791 from civicrm/4.7.31-rc
[civicrm-core.git] / tests / phpunit / WebTest / Profile / BatchUpdateTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Profile_BatchUpdateTest
31 */
32 class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testBatchUpdateWithContactSubtypes() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
41
42 // Add new individual using Quick Add block on the main page
43 $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
44 $lastName1 = "Smiths_x" . substr(sha1(rand()), 0, 7);
45 $Name1 = $lastName1 . ', ' . $firstName1;
46 $this->webtestAddContact($firstName1, $lastName1, "$firstName1.$lastName1@example.com");
47
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;
52
53 $firstName3 = "James_" . substr(sha1(rand()), 0, 7);
54 $lastName3 = "Smiths_x" . substr(sha1(rand()), 0, 7);
55 $Name3 = $lastName3 . ', ' . $firstName3;
56
57 $this->webtestAddContact($firstName2, $lastName2, "$firstName2.$lastName2@example.com", "Student");
58 $this->webtestAddContact($firstName3, $lastName3, "$firstName3.$lastName3@example.com", "Staff");
59
60 $profileTitle = 'Batch Profile test_' . substr(sha1(rand()), 0, 7);
61 $profileFields = array(
62 array(
63 'type' => 'Individual',
64 'name' => 'Last Name',
65 'label' => 'Last Name',
66 ),
67 );
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');
72
73 // Update multiple contacts
74 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
75 $this->click('CIVICRM_QFID_ts_all_4');
76
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');
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}']");
88 // selecting first check of profile
89 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[2]/input");
90
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
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
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());
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
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());
120
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
125 public function testBatchUpdate() {
126 $this->markTestSkipped('Skipping for now as it works fine locally.');
127 // Log in using webtestLogin() method
128 $this->webtestLogin();
129
130 // Add new individual using Quick Add block on the main page
131 $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
132 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
133 $Name1 = $lastName . ', ' . $firstName1;
134 $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
135
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);
144
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());
150
151 // Find Contact
152 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
153 $this->type('sort_name', $lastName);
154 $this->click('_qf_Basic_refresh');
155
156 // Update multiple contacts
157 $this->waitForElementPresent('CIVICRM_QFID_ts_all_4');
158 $this->click('CIVICRM_QFID_ts_all_4');
159
160 $this->select('task', "label=Update multiple contacts");
161 $this->waitForElementPresent('_qf_PickProfile_next');
162
163 $this->select('uf_group_id', "label={$profileTitle}");
164 $this->click('_qf_PickProfile_next');
165
166 $this->waitForElementPresent('_qf_Batch_next');
167
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}']");
170
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]");
173
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
178
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
183 sleep(5);
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]")
195 ) {
196 $assertCheck = TRUE;
197 }
198 else {
199 $assertCheck = FALSE;
200 }
201
202 $this->assertTrue($assertCheck, 'copy rows for field one failed');
203
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
208 sleep(5);
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]")
220 ) {
221 $assertCheck = TRUE;
222 }
223 else {
224 $assertCheck = FALSE;
225 }
226
227 $this->assertTrue($assertCheck, 'copy rows for field two failed');
228
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");
231
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
237 sleep(5);
238
239 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}") == $this->getValue("{$dateElementIdSecondRow}")) {
240 $assertCheck = TRUE;
241 }
242 else {
243 $assertCheck = FALSE;
244 }
245
246 $this->assertTrue($assertCheck, 'date / time coping failed');
247
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");
250
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
256 sleep(5);
257
258 if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) {
259 $assertCheck = TRUE;
260 }
261 else {
262 $assertCheck = FALSE;
263 }
264
265 $this->assertTrue($assertCheck, 'Rich Text Area coping failed');
266
267 // selecting first check of profile
268 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[6]/input");
269 // selecting second check of profile
270 $this->click("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input");
271 // clicking copy values to rows of first check and verifying
272 // if other radio Profile Field radio buttons are affected
273
274 $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[6]/img");
275 // Because it tends to cause problems, all uses of sleep() must be justified in comments
276 // Sleep should never be used for wait for anything to load from the server
277 // Justification for this instance: FIXME
278 sleep(5);
279 if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") &&
280 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") &&
281 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[3]") &&
282 //verification for second field first row
283 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input") &&
284 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[2]") &&
285 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[7]/input[3]") &&
286 //verification for first field second row
287 $this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input") &&
288 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[2]") &&
289 !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr[2]/td[6]/input[3]")
290 ) {
291 $assertCheck = TRUE;
292 }
293 else {
294 $assertCheck = FALSE;
295 }
296
297 $this->assertTrue($assertCheck, 'copy rows for field one failed[radio button]');
298
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
303 sleep(5);
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]")
315 ) {
316 $assertCheck = TRUE;
317 }
318 else {
319 $assertCheck = FALSE;
320 }
321
322 $this->assertTrue($assertCheck, 'copy rows for field two failed[radio button]');
323
324 //campaign test for interview
325 //enable CiviCampaign module if necessary
326 $this->enableComponents("CiviCampaign");
327
328 //Adding a survey
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());
345
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');
360
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}']");
363
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
371
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
376 sleep(5);
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]")
388 ) {
389 $assertCheck = TRUE;
390 }
391 else {
392 $assertCheck = FALSE;
393 }
394
395 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)');
396
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
401 sleep(5);
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]")
413 ) {
414 $assertCheck = TRUE;
415 }
416 else {
417 $assertCheck = FALSE;
418 }
419
420 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)');
421
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");
424
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
430 sleep(5);
431
432 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}") == $this->getValue("{$dateElementIdSecondRow}")) {
433 $assertCheck = TRUE;
434 }
435 else {
436 $assertCheck = FALSE;
437 }
438
439 $this->assertTrue($assertCheck, 'date / time coping failed for inteview (campaign)');
440
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
446 sleep(5);
447
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")) {
449 $assertCheck = TRUE;
450 }
451 else {
452 $assertCheck = FALSE;
453 }
454
455 $this->assertTrue($assertCheck, 'Note Custom field coping failed');
456
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
462
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
467 sleep(5);
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]")
479 ) {
480 $assertCheck = TRUE;
481 }
482 else {
483 $assertCheck = FALSE;
484 }
485
486 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]');
487
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
492 sleep(5);
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]")
504 ) {
505 $assertCheck = TRUE;
506 }
507 else {
508 $assertCheck = FALSE;
509 }
510
511 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)[radio button]');
512 $this->clickLink("_qf_Interview_cancel_interview");
513
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());
519 }
520
521 /**
522 * @param $profileTitle
523 * @param $customDataArr
524 * @param $profileFor
525 */
526 public function _addProfile($profileTitle, $customDataArr, $profileFor) {
527
528 $this->openCiviPage('admin/uf/group', 'reset=1');
529
530 $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom');
531
532 // Add membership custom data field to profile
533 $this->type('title', $profileTitle);
534
535 // Standalone form or directory
536 $this->click('uf_group_type_Profile');
537
538 $this->clickLink('_qf_Group_next-bottom');
539
540 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
541
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');
548
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;']");
553 }
554 }
555
556 /**
557 * @param $profileFor
558 *
559 * @return array
560 */
561 public function _addCustomData($profileFor) {
562 $returnArray = array();
563 $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
564
565 $this->openCiviPage('admin/custom/group', 'reset=1');
566
567 //add new custom data
568 $this->clickLink("//a[@id='newCustomDataGroup']/span");
569
570 //fill custom group title
571 $this->click("title");
572 $this->type("title", $customGroupTitle);
573
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='']");
579 }
580
581 $this->clickLink('_qf_Group_next-bottom');
582
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.");
585
586 //for checkbox 1
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");
594
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);
606
607 //setting options per line to check CRM-9938
608 $this->type("options_per_line", 2);
609
610 //clicking save
611 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
612
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);
617
618 // create another custom field - Integer Radio
619 //for checkbox 2
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");
626
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);
638
639 //clicking save
640 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
641
642 //Is custom field created
643 $this->waitForText('crm-notification-container', "Custom field '$checkLabel2' has been saved.");
644 $returnArray[2] = array($customGroupTitle, $checkLabel2);
645
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');
654
655 // enter years prior to current date
656 $this->type('start_date_years', 3);
657
658 // enter years up to the end year
659 $this->type('end_date_years', 3);
660
661 // select the date and time format
662 $this->select('date_format', "value=yy-mm-dd");
663 $this->select('time_format', "value=2");
664
665 //clicking save
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);
670
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");
679
680 //clicking save
681 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
682
683 //Is custom field created
684 $this->waitForText('crm-notification-container', "Custom field '$richTextField' has been saved.");
685 $returnArray[4] = array($customGroupTitle, $richTextField);
686
687 //create radio button field
688 //for radio 1
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");
696
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);
708
709 //clicking save
710 $this->clickLink('_qf_Field_next_new-top', '_qf_Field_done-bottom', FALSE);
711
712 //Is custom field created
713 $this->waitForText('crm-notification-container', "Custom field '$radioLabel1' has been saved.");
714 $returnArray[5] = array($customGroupTitle, $radioLabel1);
715
716 // create another custom field - Alpha Radio
717 //for radio 2
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");
725
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);
737
738 //clicking save
739 $this->clickLink('_qf_Field_done', 'newCustomField', FALSE);
740
741 //Is custom field created
742 $this->waitForText('crm-notification-container', "Custom field '$radioLabel2' has been saved.");
743 $returnArray[6] = array($customGroupTitle, $radioLabel2);
744
745 return $returnArray;
746 }
747
748 }