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