Merge pull request #115 from dlobo/CRM-12088
[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->enableComponents("CiviCampaign");
358
359 //Adding a survey
360 $this->openCiviPage('survey/add', 'reset=1', '_qf_Main_upload-bottom');
361 $surveyTitle = "BatchUpdateTest Survey" . substr(sha1(rand()), 0, 7);
362 $this->type("title", $surveyTitle);
363 $this->select('activity_type_id', 'label=Survey');
364 $this->click('_qf_Main_upload-bottom');
365 $this->waitForElementPresent('_qf_Questions_cancel-bottom');
366 $this->select("//form[@id='Questions']/div[2]/table/tbody/tr[1]/td[2]/div/div/span/select", "label={$profileTitle}");
367 $this->click('_qf_Questions_upload_next-bottom');
368 $this->waitForElementPresent('_qf_Results_cancel-bottom');
369 $this->click('CIVICRM_QFID_1_option_type');
370 $this->type('option_label_1', 'option1');
371 $this->type('option_value_1', 'option1');
372 $this->type('option_label_2', 'option2');
373 $this->type('option_value_2', 'option2');
374 $this->click('_qf_Results_upload_done-bottom');
375 $this->waitForPageToLoad($this->getTimeoutMsec());
376
377 //Reserve and interview responsedents
378 $this->openCiviPage('campaign', 'reset=1&subPage=survey');
379 $this->waitForElementPresent("xpath=//table[@id='surveys']/tbody//tr/td[2]/a[text()='{$surveyTitle}']/../following-sibling::td[@class='crm-campaign-voterLinks']/span/ul/li/a");
380 $this->click("xpath=//table[@id='surveys']/tbody//tr/td[2]/a[text()='{$surveyTitle}']/../following-sibling::td[@class='crm-campaign-voterLinks']/span/ul/li/a");
381 $this->waitForPageToLoad($this->getTimeoutMsec());
382 $this->click("xpath=//div[@id='search_form_reserve']/div");
383 $this->waitForElementPresent('sort_name');
384 $this->type('sort_name', $lastName);
385 $this->waitForElementPresent('_qf_Search_refresh');
386 $this->click('_qf_Search_refresh');
387 $this->waitForPageToLoad($this->getTimeoutMsec());
388 $this->waitForElementPresent('Go');
389 $this->click('CIVICRM_QFID_ts_all_4');
390 $this->click('Go');
391 $this->waitForElementPresent('_qf_Reserve_next_reserveToInterview-top');
392 $this->click('_qf_Reserve_next_reserveToInterview-top');
393 $this->waitForElementPresent('_qf_Interview_cancel_interview');
394
395 $this->isElementPresent("xpath=//table[@id='voterRecords']/tbody//tr/td[text()='{$Name2}']");
396 $this->isElementPresent("xpath=//table[@id='voterRecords']/tbody//tr/td[text()='{$Name1}']");
397
398 //edition to be done here
399 // selecting first check of profile
400 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[3]/input[2]");
401 // selecting second check of profile
402 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]");
403 // clicking copy values to rows of first check and verifying
404 // if other check Profile Field check box are affected
405
406 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[3]/div/img");
407 sleep(5);
408 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]") &&
409 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[4]") &&
410 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[6]") &&
411 //verification for second field first row
412 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[2]") &&
413 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[4]") &&
414 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[6]") &&
415 //verification for first field second row
416 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[2]") &&
417 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[4]") &&
418 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[6]")
419 ) {
420 $assertCheck = TRUE;
421 }
422 else $assertCheck = FALSE;
423
424 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)');
425
426 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[4]/div/img");
427 sleep(5);
428 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]") &&
429 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[4]") &&
430 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[6]") &&
431 //verification for second field first row
432 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[2]") &&
433 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[4]") &&
434 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[4]/input[6]") &&
435 //verification for first field second row
436 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[2]") &&
437 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[4]") &&
438 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[3]/input[6]")
439 ) {
440 $assertCheck = TRUE;
441 }
442 else $assertCheck = FALSE;
443
444 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)');
445
446 $dateElementIdFirstRow = $this->getAttribute("xpath=//table[@id='voterRecords']/tbody/tr/td[5]/input/@id");
447 $dateElementIdSecondRow = $this->getAttribute("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[5]/input/@id");
448
449 $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week");
450 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[5]/div/img");
451 sleep(5);
452
453 if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) {
454 $assertCheck = TRUE;
455 }
456 else $assertCheck = FALSE;
457
458 $this->assertTrue($assertCheck, 'date / time coping failed for inteview (campaign)');
459
460 $this->type("xpath=//table[@id='voterRecords']/tbody/tr/td[@class='note']/input", 'This is Test Introductory Message');
461 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[8]/div/img");
462 sleep(5);
463
464 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")) {
465 $assertCheck = TRUE;
466 }
467 else $assertCheck = FALSE;
468
469 $this->assertTrue($assertCheck, 'Note Custom field coping failed');
470
471 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[6]/input");
472 // selecting second check of profile
473 $this->click("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input");
474 // clicking copy values to rows of first check and verifying
475 // if other radio Profile Field radio buttons are affected
476
477 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[6]/div/img");
478 sleep(5);
479 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input") &&
480 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[2]") &&
481 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[3]") &&
482 //verification for second field first row
483 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input") &&
484 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[2]") &&
485 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[3]") &&
486 //verification for first field second row
487 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input") &&
488 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[2]") &&
489 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[3]")
490 ) {
491 $assertCheck = TRUE;
492 }
493 else $assertCheck = FALSE;
494
495 $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]');
496
497 $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[7]/div/img");
498 sleep(5);
499 if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input") &&
500 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[2]") &&
501 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[3]") &&
502 //verification for second field first row
503 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input") &&
504 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[2]") &&
505 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[7]/input[3]") &&
506 //verification for first field second row
507 $this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input") &&
508 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[2]") &&
509 !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[6]/input[3]")
510 ) {
511 $assertCheck = TRUE;
512 }
513 else $assertCheck = FALSE;
514
515 $this->assertTrue($assertCheck, 'copy rows for field two failed for inteview (campaign)[radio button]');
516
517 //change the editor back to ckeditor
518 $this->openCiviPage('admin/setting/preferences/display', 'reset=1', '_qf_Display_next-bottom');
519 $this->select('editor_id', 'CKEditor');
520 $this->click('_qf_Display_next-bottom');
521 $this->waitForPageToLoad($this->getTimeoutMsec());
522 }
523
524 function _addProfile($profileTitle, $customDataArr, $profileFor) {
525 // Go directly to the URL of the screen that you will be testing (New Profile).
526 $this->openCiviPage('admin/uf/group', 'reset=1');
527
528 $this->click('link=Add Profile');
529
530 // Add membership custom data field to profile
531 $this->waitForElementPresent('_qf_Group_cancel-bottom');
532 $this->type('title', $profileTitle);
533 $this->click('_qf_Group_next-bottom');
534
535 $this->waitForElementPresent('_qf_Field_cancel-bottom');
536 $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
537
538 foreach ($customDataArr as $key => $customDataParams) {
539 $this->select('field_name[0]', "label={$profileFor}");
540 $this->select('field_name[1]', "label={$customDataParams[1]} :: {$customDataParams[0]}");
541 $this->click('field_name[1]');
542 $this->click('label');
543
544 // Clicking save and new
545 $this->click('_qf_Field_next_new-bottom');
546 $this->waitForPageToLoad($this->getTimeoutMsec());
547 $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[1]}' has been saved to '{$profileTitle}'.");
548 }
549 }
550
551 function _addCustomData($profileFor) {
552 $returnArray = array();
553 $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
554 // Go directly to the URL of the screen that you will be testing (New Custom Group).
555 $this->openCiviPage('admin/custom/group', 'reset=1');
556
557 //add new custom data
558 $this->click("//a[@id='newCustomDataGroup']/span");
559 $this->waitForPageToLoad($this->getTimeoutMsec());
560
561 //fill custom group title
562 $this->click("title");
563 $this->type("title", $customGroupTitle);
564
565 //custom group extends
566 $this->click("extends[0]");
567 $this->select("extends[0]", "label={$profileFor}");
568 if ($this->isElementPresent('//option')) {
569 $this->click("//option[@value='']");
570 }
571
572 $this->click('_qf_Group_next-bottom');
573 $this->waitForElementPresent('_qf_Field_cancel-bottom');
574
575 //Is custom group created?
576 $this->assertElementContainsText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
577
578 //for checkbox 1
579 $checkLabel1 = 'Custom Check One Text_' . substr(sha1(rand()), 0, 4);
580 $this->type('label', $checkLabel1);
581 $this->click('data_type[0]');
582 $this->select('data_type[0]', "label=Alphanumeric");
583 $this->select('data_type[1]', "label=CheckBox");
584
585 // enter checkbox options
586 $checkOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
587 $this->type('option_label_1', $checkOneOptionLabel1);
588 $this->type('option_value_1', 1);
589 $checkOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
590 $this->type('option_label_2', $checkOneOptionLabel2);
591 $this->type('option_value_2', 2);
592 $this->click("link=another choice");
593 $checkOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
594 $this->type('option_label_3', $checkOneOptionLabel3);
595 $this->type('option_value_3', 3);
596
597 //setting options per line to check CRM-9938
598 $this->type("options_per_line", 2);
599
600 //clicking save
601 $this->click('_qf_Field_next');
602 $this->waitForPageToLoad($this->getTimeoutMsec());
603
604 //Is custom field created
605 $this->assertElementContainsText('crm-notification-container', "Your custom field '$checkLabel1' has been saved.");
606 $returnArray[1] = array($customGroupTitle, $checkLabel1);
607
608 // create another custom field - Integer Radio
609 $this->click("//a[@id='newCustomField']/span");
610 $this->waitForPageToLoad($this->getTimeoutMsec());
611
612 //for checkbox 2
613 $checkLabel2 = 'Custom Check Two Text_' . substr(sha1(rand()), 0, 4);
614 $this->type('label', $checkLabel2);
615 $this->click('data_type[0]');
616 $this->select('data_type[0]', "label=Alphanumeric");
617 $this->select('data_type[1]', "label=CheckBox");
618
619 // enter checkbox options
620 $checkTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
621 $this->type('option_label_1', $checkTwoOptionLabel1);
622 $this->type('option_value_1', 1);
623 $checkTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
624 $this->type('option_label_2', $checkTwoOptionLabel2);
625 $this->type('option_value_2', 2);
626 $this->click("link=another choice");
627 $checkTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
628 $this->type('option_label_3', $checkTwoOptionLabel3);
629 $this->type('option_value_3', 3);
630
631 //clicking save
632 $this->click('_qf_Field_next');
633 $this->waitForPageToLoad($this->getTimeoutMsec());
634
635 //Is custom field created
636 $this->assertElementContainsText('crm-notification-container', "Your custom field '$checkLabel2' has been saved.");
637 $returnArray[2] = array($customGroupTitle, $checkLabel2);
638
639 // create another custom field - Integer Radio
640 $this->click("//a[@id='newCustomField']/span");
641 $this->waitForPageToLoad($this->getTimeoutMsec());
642
643 // create another custom field - Date
644 $dateFieldLabel = 'Custom Date Field' . substr(sha1(rand()), 0, 4);
645 $this->type('label', $dateFieldLabel);
646 $this->click('data_type[0]');
647 $this->select('data_type[0]', "label=Date");
648 $this->waitForElementPresent('start_date_years');
649
650 // enter years prior to current date
651 $this->type('start_date_years', 3);
652
653 // enter years upto the end year
654 $this->type('end_date_years', 3);
655
656 // select the date and time format
657 $this->select('date_format', "value=yy-mm-dd");
658 $this->select('time_format', "value=2");
659
660 //clicking save
661 $this->click('_qf_Field_next');
662 $this->waitForPageToLoad($this->getTimeoutMsec());
663
664 //Is custom field created
665 $this->assertElementContainsText('crm-notification-container', "Your custom field '$dateFieldLabel' has been saved.");
666 $returnArray[3] = array($customGroupTitle, $dateFieldLabel);
667
668 // create another custom field - Integer Radio
669 $this->click("//a[@id='newCustomField']/span");
670 $this->waitForPageToLoad($this->getTimeoutMsec());
671
672 //create rich text editor field
673 $richTextField = 'Custom Rich TextField_' . substr(sha1(rand()), 0, 4);
674 $this->type('label', $richTextField);
675 $this->click('data_type[0]');
676 $this->select('data_type[0]', "label=Note");
677 $this->select('data_type[1]', "label=RichTextEditor");
678
679 //clicking save
680 $this->click('_qf_Field_next');
681 $this->waitForPageToLoad($this->getTimeoutMsec());
682
683 //Is custom field created
684 $this->assertElementContainsText('crm-notification-container', "Your custom field '$richTextField' has been saved.");
685 $returnArray[4] = array($customGroupTitle, $richTextField);
686
687 // create another custom field - Integer Radio
688 $this->click("//a[@id='newCustomField']/span");
689 $this->waitForPageToLoad($this->getTimeoutMsec());
690
691 //create radio button field
692 //for radio 1
693 $radioLabel1 = 'Custom Radio One Text_' . substr(sha1(rand()), 0, 4);
694 $this->type('label', $radioLabel1);
695 $this->click('data_type[0]');
696 $this->select('data_type[0]', "label=Alphanumeric");
697 $this->select('data_type[1]', "label=Radio");
698
699 // enter radio options
700 $radioOneOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
701 $this->type('option_label_1', $radioOneOptionLabel1);
702 $this->type('option_value_1', 1);
703 $radioOneOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
704 $this->type('option_label_2', $radioOneOptionLabel2);
705 $this->type('option_value_2', 2);
706 $this->click("link=another choice");
707 $radioOneOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
708 $this->type('option_label_3', $radioOneOptionLabel3);
709 $this->type('option_value_3', 3);
710
711 //clicking save
712 $this->click('_qf_Field_next');
713 $this->waitForPageToLoad($this->getTimeoutMsec());
714
715 //Is custom field created
716 $this->assertElementContainsText('crm-container', "Your custom field '$radioLabel1' has been saved.");
717 $returnArray[5] = array($customGroupTitle, $radioLabel1);
718
719 // create another custom field - Integer Radio
720 $this->click("//a[@id='newCustomField']/span");
721 $this->waitForPageToLoad($this->getTimeoutMsec());
722
723 //for radio 2
724 $radioLabel2 = 'Custom Radio Two Text_' . substr(sha1(rand()), 0, 4);
725 $this->type('label', $radioLabel2);
726 $this->click('data_type[0]');
727 $this->select('data_type[0]', "label=Alphanumeric");
728 $this->select('data_type[1]', "label=Radio");
729
730 // enter radio options
731 $radioTwoOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
732 $this->type('option_label_1', $radioTwoOptionLabel1);
733 $this->type('option_value_1', 1);
734 $radioTwoOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
735 $this->type('option_label_2', $radioTwoOptionLabel2);
736 $this->type('option_value_2', 2);
737 $this->click("link=another choice");
738 $radioTwoOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
739 $this->type('option_label_3', $radioTwoOptionLabel3);
740 $this->type('option_value_3', 3);
741
742 //clicking save
743 $this->click('_qf_Field_next');
744 $this->waitForPageToLoad($this->getTimeoutMsec());
745
746 //Is custom field created
747 $this->assertElementContainsText('crm-notification-container', "Your custom field '$radioLabel2' has been saved.");
748 $returnArray[6] = array($customGroupTitle, $radioLabel2);
749
750 return $returnArray;
751 }
752 }