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