Merge pull request #2991 from colemanw/master
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / MailingTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
6a488035 5 +--------------------------------------------------------------------+
06a1bc01 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*/
26
6a488035
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testAddMailing() {
6a488035
TO
35 $this->webtestLogin();
36
37 //----do create test mailing group
e8743663 38 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
6a488035
TO
39
40 // make group name
41 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
42
43 // fill group name
44 $this->type("title", $groupName);
45
46 // fill description
47 $this->type("description", "New mailing group for Webtest");
48
49 // enable Mailing List
50 $this->click("group_type[2]");
51
52 // select Visibility as Public Pages
53 $this->select("visibility", "value=Public Pages");
54
55 // Clicking save.
d317a853 56 $this->clickLink("_qf_Edit_upload");
6a488035
TO
57
58 // Is status message correct?
6c5f7368 59 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
6a488035
TO
60
61 //---- create mailing contact and add to mailing Group
62 $firstName = substr(sha1(rand()), 0, 7);
63 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
64
65 // Get contact id from url.
a471a3b6 66 $contactId = $this->urlArg('cid');
6a488035
TO
67
68 // go to group tab and add to mailing group
69 $this->click("css=li#tab_group a");
70 $this->waitForElementPresent("_qf_GroupContact_next");
71 $this->select("group_id", "$groupName");
45fabf8e 72 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
6a488035
TO
73
74 // configure default mail-box
5ff68892 75 $this->setupDefaultMailbox();
6a488035 76
e8743663 77 $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel");
6a488035
TO
78
79 //-------select recipients----------
80
81 // fill mailing name
82 $mailingName = substr(sha1(rand()), 0, 7);
83 $this->type("name", "Mailing $mailingName Webtest");
84
85 // Add the test mailing group
86 $this->select("includeGroups-f", "$groupName");
87 $this->click("add");
88
89 // click next
45fabf8e 90 $this->clickLink("_qf_Group_next", "_qf_Settings_cancel", FALSE);
6a488035
TO
91
92 //--------track and respond----------
93
94 // check for default settings options
95 $this->assertChecked("url_tracking");
96 $this->assertChecked("open_tracking");
97
98 // do check count for Recipient
e8743663 99 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
100
101 // no need tracking for this test
102
103 // click next with default settings
d317a853 104 $this->clickLink("_qf_Settings_next", "_qf_Upload_cancel");
6a488035 105
6a488035
TO
106 //--------Mailing content------------
107 // let from email address be default
108
109 // fill subject for mailing
110 $this->type("subject", "Test subject {$mailingName} for Webtest");
111
112 // check for default option enabled
113 $this->assertChecked("CIVICRM_QFID_1_upload_type");
114
115 // HTML format message
116 $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
117 $this->fillRichTextField("html_message", $HTMLMessage);
118
119 // Open Plain-text Format pane and type text format msg
120 $this->click("//fieldset[@id='compose_id']/div[2]/div[1]");
121 $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest.");
122
6a488035
TO
123 // select default header and footer ( with label )
124 $this->select("header_id", "label=Mailing Header");
125 $this->select("footer_id", "label=Mailing Footer");
126
127 // do check count for Recipient
e8743663 128 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
129
130 // click next with nominal content
d317a853 131 $this->clickLink("_qf_Upload_upload", "_qf_Test_cancel");
6a488035
TO
132
133 //---------------Test------------------
134
135 ////////--Commenting test mailing and mailing preview (test mailing and preview not presently working).
136
137 // send test mailing
138 //$this->type("test_email", "mailino@mailson.co.in");
139 //$this->click("sendtest");
140
141 // verify status message
142 //$this->assertTrue($this->isTextPresent("Your test message has been sent. Click 'Next' when you are ready to Schedule or Send your live mailing (you will still have a chance to confirm or cancel sending this mailing on the next page)."));
143
144 // check mailing preview
145 //$this->click("//form[@id='Test']/div[2]/div[4]/div[1]");
146 //$this->assertTrue($this->isTextPresent("this is test content for Mailing $mailingName Webtest"));
147
148 ////////
149
150 // do check count for Recipient
e8743663 151 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
152
153 // click next
d317a853 154 $this->clickLink("_qf_Test_next", "_qf_Schedule_cancel");
6a488035
TO
155
156 //----------Schedule or Send------------
157
158 // do check for default option enabled
159 $this->assertChecked("now");
160
161 // do check count for Recipient
e8743663 162 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
163
164 // finally schedule the mail by clicking submit
d317a853 165 $this->clickLink("_qf_Schedule_next");
6a488035
TO
166
167 //----------end New Mailing-------------
168
169 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
83739141 170 $this->assertElementContainsText('page-title', "Find Mailings");
45fabf8e 171 $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest");
6a488035
TO
172
173 //--------- mail delivery verification---------
6a488035
TO
174 // test undelivered report
175
176 // click report link of created mailing
d317a853 177 $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
6a488035
TO
178
179 // verify undelivered status message
e8743663 180 $this->assertElementContainsText('css=.messages', "Delivery has not yet begun for this mailing. If the scheduled delivery date and time is past, ask the system administrator or technical support contact for your site to verify that the automated mailer task ('cron job') is running - and how frequently.");
6a488035
TO
181
182 // do check for recipient group
e8743663 183 $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
6a488035
TO
184
185 // directly send schedule mailing -- not working right now
e8743663 186 $this->openCiviPage("mailing/queue", "reset=1");
6a488035
TO
187
188 //click report link of created mailing
d317a853 189 $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
6a488035
TO
190
191 // do check again for recipient group
e8743663 192 $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
6a488035
TO
193
194 // verify intended recipients
195 $this->verifyText("xpath=//table//tr[td/a[text()='Intended Recipients']]/descendant::td[2]", preg_quote("1"));
196
197 // verify successful deliveries
198 $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)"));
199
200 // verify status
201 $this->verifyText("xpath=//table//tr[td[1]/text()='Status']/descendant::td[2]", preg_quote("Complete"));
202
203 // verify mailing name
204 $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest"));
205
206 // verify mailing subject
207 $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest"));
208
209 //---- check for delivery detail--
210
d317a853 211 $this->clickLink("link=Successful Deliveries");
6a488035
TO
212
213 // check for open page
e8743663 214 $this->assertElementContainsText( 'page-title', "Successful Deliveries");
6a488035
TO
215
216 // verify email
e8743663 217 $this->verifyText("xpath=//table[@id='mailing_event']/tbody//tr/td[2]", preg_quote("mailino$firstName@mailson.co.in"));
6a488035 218
6a488035
TO
219 $eventQueue = new CRM_Mailing_Event_DAO_Queue();
220 $eventQueue->contact_id = $contactId;
221 $eventQueue->find(TRUE);
222
223 $permission = array('edit-1-access-civimail-subscribeunsubscribe-pages');
224 $this->changePermissions($permission);
42daf119 225 $this->webtestLogout();
6a488035
TO
226
227 // build forward url
e8743663 228 $forwardUrl = array("mailing/forward", "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}");
fb67d37e 229 $this->openCiviPage($forwardUrl[0], $forwardUrl[1], NULL);
6a488035
TO
230
231 $this->type("email_0", substr(sha1(rand()), 0, 7) . '@example.com');
232 $this->type("email_1", substr(sha1(rand()), 0, 7) . '@example.com');
233
234 $this->click("comment_show");
235 $this->type("forward_comment", "Test Message");
236
237 $this->click("_qf_ForwardMailing_next-bottom");
238 $this->waitForPageToLoad($this->getTimeoutMsec());
e8743663 239 $this->assertElementContainsText('css=div.messages', 'Mailing is forwarded successfully to 2 email addresses');
6a488035 240
6a488035
TO
241 $this->webtestLogin();
242
e8743663 243 $this->openCiviPage("mailing/browse/scheduled", "reset=1&scheduled=true");
6a488035
TO
244
245 //click report link of created mailing
d317a853 246 $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
6a488035
TO
247
248 // verify successful forwards
249 $this->verifyText("xpath=//table//tr[td/a[text()='Forwards']]/descendant::td[2]", "2");
250
251 // Mailing is forwarded successfully to 2 email addresses.
252 //------end delivery verification---------
253
254 // //------ check with unsubscribe -------
255 // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by seperate DSN setting for Webtests
256 // // build unsubscribe link
257 // require_once 'CRM/Mailing/Event/DAO/Queue.php';
258 // $eventQueue = new CRM_Mailing_Event_DAO_Queue( );
259 // $eventQueue->contact_id = $contactId;
260 // $eventQueue->find(true);
261
262 // // unsubscribe link
263 // $unsubscribeUrl = "civicrm/mailing/optout?reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}&confirm=1";
264
265 // // logout to unsubscribe
42daf119 266 // $this->webtestLogout();
6a488035
TO
267
268 // // click(visit) unsubscribe path
269 // $this->open($this->sboxPath . $unsubscribeUrl);
270 // $this->waitForPageToLoad($this->getTimeoutMsec());
271
272 // $this->assertTrue($this->isTextPresent('Optout'));
273 // $this->assertTrue($this->isTextPresent("mailino$firstName@mailson.co.in"));
274
275 // // unsubscribe
276 // $this->click('_qf_optout_next');
277 // $this->waitForPageToLoad($this->getTimeoutMsec());
278
279 // $this->assertTrue($this->isTextPresent('Optout'));
280 // $this->assertTrue($this->isTextPresent("mailino$firstName@mailson.co.in"));
281 // $this->assertTrue($this->isTextPresent('has been successfully opted out.'));
282
283 // //------ end unsubscribe -------
284 }
76e86fd8 285
6a488035
TO
286 function testAdvanceSearchAndReportCheck() {
287
6a488035
TO
288 $this->webtestLogin();
289
e8743663 290 $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload");
6a488035
TO
291
292 // make group name
293 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
294
295 // fill group name
296 $this->type("title", $groupName);
297
298 // fill description
299 $this->type("description", "New mailing group for Webtest");
300
301 // enable Mailing List
302 $this->click("group_type[2]");
303
304 // select Visibility as Public Pages
305 $this->select("visibility", "value=Public Pages");
306
307 // Clicking save.
d317a853 308 $this->clickLink("_qf_Edit_upload");
6a488035
TO
309
310 // Is status message correct?
6c5f7368 311 $this->waitForText('crm-notification-container', "The Group '$groupName' has been saved.");
6a488035
TO
312
313 //---- create mailing contact and add to mailing Group
314 $firstName = substr(sha1(rand()), 0, 7);
315 $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in");
316
317 // Get contact id from url.
a471a3b6 318 $contactId = $this->urlArg('cid');
6a488035
TO
319
320 // go to group tab and add to mailing group
321 $this->click("css=li#tab_group a");
322 $this->waitForElementPresent("_qf_GroupContact_next");
323 $this->select("group_id", "$groupName");
45fabf8e 324 $this->clickLink("_qf_GroupContact_next", "_qf_GroupContact_next", FALSE);
6a488035
TO
325
326 // configure default mail-box
e8743663 327 $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", '_qf_MailSettings_cancel-bottom');
6a488035
TO
328 $this->type('name', 'Test Domain');
329 $this->type('domain', 'example.com');
330 $this->select('protocol', 'value=1');
d317a853 331 $this->clickLink('_qf_MailSettings_next-bottom');
6a488035 332
42daf119 333 // Go to Schedule and Send Mailing form
fb67d37e 334 $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel');
6a488035
TO
335
336 //-------select recipients----------
337
338 // fill mailing name
339 $mailingName = substr(sha1(rand()), 0, 7);
340 $this->type("name", "Mailing $mailingName Webtest");
341
342 // Add the test mailing group
343 $this->select("includeGroups-f", "$groupName");
344 $this->click("add");
345
346 // click next
347 $this->click("_qf_Group_next");
348 $this->waitForElementPresent("_qf_Settings_cancel");
349
350 //--------track and respond----------
351
352 // check for default settings options
353 $this->assertChecked("url_tracking");
354 $this->assertChecked("open_tracking");
355
356 // do check count for Recipient
e8743663 357 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
358
359 // click next with default settings
d317a853 360 $this->clickLink("_qf_Settings_next");
6a488035
TO
361
362 // fill subject for mailing
363 $this->type("subject", "Test subject {$mailingName} for Webtest");
76e86fd8 364
6a488035
TO
365 // check for default option enabled
366 $this->assertChecked("CIVICRM_QFID_1_upload_type");
367
368 // HTML format message
369 $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
370 $this->fillRichTextField("html_message", $HTMLMessage);
371
372 // Open Plain-text Format pane and type text format msg
373 $this->click("//fieldset[@id='compose_id']/div[2]/div[1]");
374 $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest.");
375
376 // select default header and footer ( with label )
377 $this->select("header_id", "label=Mailing Header");
378 $this->select("footer_id", "label=Mailing Footer");
379
380 // do check count for Recipient
e8743663 381 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
382
383 // click next with nominal content
d317a853 384 $this->clickLink("_qf_Upload_upload", "_qf_Test_cancel");
6a488035
TO
385
386 // do check count for Recipient
e8743663 387 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
388
389 // click next
d317a853 390 $this->clickLink("_qf_Test_next", "_qf_Schedule_cancel");
6a488035
TO
391
392 //----------Schedule or Send------------
393
394 // do check for default option enabled
395 $this->assertChecked("now");
396
397 // do check count for Recipient
e8743663 398 $this->assertElementContainsText('css=.messages', "Total Recipients: 1");
6a488035
TO
399
400 // finally schedule the mail by clicking submit
d317a853 401 $this->clickLink("_qf_Schedule_next");
6a488035
TO
402
403 //----------end New Mailing-------------
404
405 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
45fabf8e 406 $this->assertElementContainsText('page-title', "Find Mailings");
407 $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest");
6a488035
TO
408
409 // directly send schedule mailing -- not working right now
e8743663 410 $this->openCiviPage("mailing/queue", "reset=1");
6a488035
TO
411
412 //click report link of created mailing
d317a853 413 $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
e8743663 414
6a488035
TO
415 $mailingReportUrl = $this->getLocation();
416 // do check again for recipient group
e8743663 417 $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
6a488035 418
e8743663
PJ
419 // verify successful deliveries
420 $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)"));
6a488035
TO
421
422 $summaryInfoLinks = array('Intended Recipients', 'Successful Deliveries', 'Tracked Opens', 'Click-throughs', 'Forwards', 'Replies', 'Bounces', 'Unsubscribe Requests','Opt-out Requests');
76e86fd8 423
6a488035
TO
424 //check for report and adv search links
425 foreach($summaryInfoLinks as $value) {
426 $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[1][text()='Report']"), "Report link missing for {$value}");
427 $this->assertTrue($this->isElementPresent("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$value}']]/descendant::td[3]/span/a[2][text()='Advanced Search']"), "Advance Search link missing for {$value}");
428}
429 // verify mailing name
430 $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest"));
431
432 // verify mailing subject
e8743663 433 $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest"));
6a488035 434
e8743663
PJ
435 // after asserts do clicks and confirm filters
436 $criteriaCheck =
6a488035 437 array(
e8743663 438 'Intended Recipients' =>
6a488035
TO
439 array(
440 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"),
441 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest")
442 ),
443 'Successful Deliveries' =>
444 array(
445 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest",
e8743663 446 "Delivery Status" => " Successful"),
6a488035
TO
447 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing Delivery -' => "Successful")
448 ),
449 'Tracked Opens' =>
450 array(
451 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"),
452 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable Opens -' => "Opened")
453 ),
454 'Click-throughs' =>
455 array(
456 'report' => array('report_name' => 'Mail Clickthroughs', 'Mailing' => "Mailing $mailingName Webtest"),
457 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable URL Clicks -' => "Clicked")
458 ),
459 'Forwards' =>
460 array(
461 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest",
e8743663 462 'Forwarded' => 'Is equal to Yes'),
6a488035
TO
463 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards")
464 ),
465 'Replies' =>
466 array(
467 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest",
e8743663 468 'Replied' => 'Is equal to Yes'),
6a488035
TO
469 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: Trackable Replies -' => "Replied")
470 ),
471 'Bounces' =>
472 array(
473 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"),
474 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing Delivery -' => "Bounced")
475 ),
476 'Unsubscribe Requests' =>
477 array(
478 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest",
e8743663 479 'Unsubscribed' => 'Is equal to Yes'),
6a488035
TO
480 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Unsubscribe Requests")
481 ),
482 'Opt-out Requests' =>
483 array(
484 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest",
e8743663 485 'Opted-out' => 'Is equal to Yes'),
6a488035
TO
486 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Opt-out Requests")
487 ),
488 );
489 $this->criteriaCheck($criteriaCheck, $mailingReportUrl);
490 }
e8743663 491
6a488035
TO
492 function criteriaCheck($criteriaCheck, $mailingReportUrl) {
493 foreach($criteriaCheck as $key => $infoFilter) {
494 foreach($infoFilter as $entity => $dataToCheck) {
495 $this->open($mailingReportUrl);
496 if ($entity == "report") {
d317a853 497 $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[1][text()='Report']");
6a488035 498 } else {
d317a853 499 $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[2][text()='Advanced Search']");
6a488035 500 }
6a488035
TO
501 $this-> _verifyCriteria($key, $dataToCheck, $entity);
502 }
503 }
504 }
e8743663 505
6a488035
TO
506 function _verifyCriteria($summaryInfo, $dataToCheck, $entity) {
507 foreach($dataToCheck as $key => $value) {
508 if ($entity == 'report') {
509 if ($key == 'report_name') {
e8743663 510 $this->assertElementContainsText('page-title', "{$value}");
6a488035
TO
511 continue;
512 }
513 $this->assertTrue($this->isElementPresent("xpath=//form//div[3]/table/tbody//tr/th[contains(text(),'{$key}')]/../td[contains(text(),'{$value}')]"),"Criteria check for {$key} failed for Report for {$summaryInfo}");
514 } else {
e8743663 515 $this->assertElementContainsText('page-title', "Advanced Search");
6a488035
TO
516 $assertedValue = $this->isElementPresent("xpath=//div[@class='crm-results-block']//div[@class='qill'][contains(text(),'{$key} {$value}')]");
517 if (!$assertedValue) {
518 $assertedValue = $this->isTextPresent("{$key} {$value}");
519 }
520 $this->assertTrue($assertedValue,"Criteria check for {$key} failed for Advance Search for {$summaryInfo}");
521 }
522 }
e8743663 523 }
42daf119 524}