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