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