Merge pull request #5512 from mallezie/notes-addTextarea-16178
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / MailingTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 )
120 $this->click("xpath=//ul/li/a[text()='Header and Footer']");
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
127 $this->click("xpath=//ul/li/a[text()='Tracking']");
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 -------
256 // // FIX ME: there is an issue with DSN setting for Webtest, need to handle by seperate DSN setting for Webtests
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');
6a488035
TO
329 $this->type('name', 'Test Domain');
330 $this->type('domain', 'example.com');
331 $this->select('protocol', 'value=1');
d317a853 332 $this->clickLink('_qf_MailSettings_next-bottom');
6a488035 333
b812c745 334 $this->openCiviPage("a/#/mailing/new");
6a488035
TO
335
336 //-------select recipients----------
c79c8ec8 337 $tokens = ' {domain.address}{action.optOutUrl}';
6a488035
TO
338
339 // fill mailing name
340 $mailingName = substr(sha1(rand()), 0, 7);
b812c745 341 $this->waitForElementPresent("xpath=//input[@name='mailingName']");
342 $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest");
6a488035
TO
343
344 // Add the test mailing group
b812c745 345 $this->select2("s2id_crmUiId_8", $groupName, TRUE);
6a488035
TO
346
347 // do check count for Recipient
b812c745 348 $this->waitForTextPresent("~1 recipient");
6a488035
TO
349
350 // fill subject for mailing
b812c745 351 $this->type("xpath=//input[@name='subject']", "Test subject {$mailingName} for Webtest");
6a488035
TO
352
353 // HTML format message
354 $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
c79c8ec8
CW
355 $this->fillRichTextField("crmUiId_1", $HTMLMessage . $tokens);
356
357 // FIXME: Selenium can't access content in an iframe
358 //$this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as HTML']");
359 //$this->waitForElementPresent($HTMLMessage);
360 //$this->waitForAjaxContent();
361 //$this->click("xpath=//button[@title='Close']");
6a488035
TO
362
363 // Open Plain-text Format pane and type text format msg
c79c8ec8
CW
364 $this->click("//div[starts-with(text(),'Plain Text')]");
365 $this->type("xpath=//*[@name='body_text']", "This is text formatted content for Mailing {$mailingName} Webtest.$tokens");
b812c745 366
367 $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']");
368 $this->waitForTextPresent("This is text formatted content for Mailing {$mailingName} Webtest.");
369 $this->waitForAjaxContent();
370 $this->click("xpath=//button[@title='Close']");
6a488035
TO
371
372 // select default header and footer ( with label )
b812c745 373 $this->click("xpath=//ul/li/a[text()='Header and Footer']");
374 $this->select2("s2id_crmUiId_10", "Mailing Header");
375 $this->select2("s2id_crmUiId_11", "Mailing Footer");
6a488035 376
b812c745 377 //--------track and respond----------
6a488035 378
b812c745 379 // check for default settings options
380 $this->click("xpath=//ul/li/a[text()='Tracking']");
381 $this->assertChecked("url_tracking");
382 $this->assertChecked("open_tracking");
6a488035 383
b812c745 384 // click next with default settings
385 $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']");
6a488035 386
b812c745 387 $this->waitForTextPresent("Mailing $mailingName Webtest");
388 $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']");
388ffbf6 389 $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in"));
b812c745 390 $this->click("xpath=//button[@title='Close']");
391 $this->waitForTextPresent("(Include: $groupName)");
6a488035
TO
392
393 //----------Schedule or Send------------
394
395 // do check for default option enabled
b812c745 396 $this->assertChecked("xpath=//input[@id='schedule-send-now']");
6a488035 397
b812c745 398 // click next with nominal content
399 $this->click("xpath=//center/a/div[text()='Submit Mailing']");
6a488035
TO
400
401 //----------end New Mailing-------------
402
403 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
b812c745 404 $this->waitForTextPresent("Find Mailings");
45fabf8e 405 $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody//tr//td", "Mailing $mailingName Webtest");
6a488035
TO
406
407 // directly send schedule mailing -- not working right now
e8743663 408 $this->openCiviPage("mailing/queue", "reset=1");
6a488035
TO
409
410 //click report link of created mailing
d317a853 411 $this->clickLink("xpath=//table//tbody/tr[td[1]/text()='Mailing $mailingName Webtest']/descendant::a[text()='Report']");
e8743663 412
6a488035
TO
413 $mailingReportUrl = $this->getLocation();
414 // do check again for recipient group
e8743663 415 $this->assertElementContainsText("xpath=//fieldset/legend[text()='Recipients']/../table/tbody//tr/td", "Members of $groupName");
6a488035 416
e8743663
PJ
417 // verify successful deliveries
418 $this->verifyText("xpath=//table//tr[td/a[text()='Successful Deliveries']]/descendant::td[2]", preg_quote("1 (100.00%)"));
6a488035 419
92915c55
TO
420 $summaryInfoLinks = array(
421 'Intended Recipients',
422 'Successful Deliveries',
423 'Tracked Opens',
424 'Click-throughs',
425 'Forwards',
426 'Replies',
427 'Bounces',
428 'Unsubscribe Requests',
795492f3 429 'Opt-out Requests',
92915c55 430 );
76e86fd8 431
6a488035 432 //check for report and adv search links
22e263ad 433 foreach ($summaryInfoLinks as $value) {
6a488035
TO
434 $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}");
435 $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 436 }
6a488035
TO
437 // verify mailing name
438 $this->verifyText("xpath=//table//tr[td[1]/text()='Mailing Name']/descendant::td[2]", preg_quote("Mailing $mailingName Webtest"));
439
440 // verify mailing subject
e8743663 441 $this->verifyText("xpath=//table//tr[td[1]/text()='Subject']/descendant::td[2]", preg_quote("Test subject $mailingName for Webtest"));
6a488035 442
e8743663 443 // after asserts do clicks and confirm filters
795492f3
TO
444 $criteriaCheck = array(
445 'Intended Recipients' => array(
446 'report' => array('report_name' => 'Mailing Details', 'Mailing' => "Mailing $mailingName Webtest"),
447 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest"),
448 ),
449 'Successful Deliveries' => array(
450 'report' => array(
451 'report_name' => 'Mailing Details',
452 'Mailing' => "Mailing $mailingName Webtest",
453 "Delivery Status" => " Successful",
454 ),
455 'search' => array(
456 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
457 'Mailing Delivery -' => "Successful",
458 ),
459 ),
460 'Tracked Opens' => array(
461 'report' => array('report_name' => 'Mail Opened', 'Mailing' => "Mailing $mailingName Webtest"),
462 'search' => array(
463 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
464 'Mailing: Trackable Opens -' => "Opened",
465 ),
466 ),
467 'Click-throughs' => array(
468 'report' => array('report_name' => 'Mail Clickthroughs', 'Mailing' => "Mailing $mailingName Webtest"),
469 'search' => array(
470 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
471 'Mailing: Trackable URL Clicks -' => "Clicked",
472 ),
473 ),
474 'Forwards' => array(
475 'report' => array(
476 'report_name' => 'Mailing Details',
477 'Mailing' => "Mailing $mailingName Webtest",
478 'Forwarded' => 'Is equal to Yes',
479 ),
480 'search' => array('Mailing Name IN' => "\"Mailing {$mailingName} Webtest", 'Mailing: -' => "Forwards"),
481 ),
482 'Replies' => array(
483 'report' => array(
484 'report_name' => 'Mailing Details',
485 'Mailing' => "Mailing $mailingName Webtest",
486 'Replied' => 'Is equal to Yes',
487 ),
488 'search' => array(
489 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
490 'Mailing: Trackable Replies -' => "Replied",
491 ),
492 ),
493 'Bounces' => array(
494 'report' => array('report_name' => 'Mail Bounces', 'Mailing' => "Mailing $mailingName Webtest"),
495 'search' => array(
496 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
497 'Mailing Delivery -' => "Bounced",
498 ),
499 ),
500 'Unsubscribe Requests' => array(
501 'report' => array(
502 'report_name' => 'Mailing Details',
503 'Mailing' => "Mailing $mailingName Webtest",
504 'Unsubscribed' => 'Is equal to Yes',
505 ),
506 'search' => array(
507 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
508 'Mailing: -' => "Unsubscribe Requests",
509 ),
510 ),
511 'Opt-out Requests' => array(
512 'report' => array(
513 'report_name' => 'Mailing Details',
514 'Mailing' => "Mailing $mailingName Webtest",
515 'Opted-out' => 'Is equal to Yes',
516 ),
517 'search' => array(
518 'Mailing Name IN' => "\"Mailing {$mailingName} Webtest",
519 'Mailing: -' => "Opt-out Requests",
520 ),
521 ),
522 );
6a488035
TO
523 $this->criteriaCheck($criteriaCheck, $mailingReportUrl);
524 }
e8743663 525
4cbe18b8
EM
526 /**
527 * @param $criteriaCheck
528 * @param $mailingReportUrl
529 */
00be9182 530 public function criteriaCheck($criteriaCheck, $mailingReportUrl) {
22e263ad
TO
531 foreach ($criteriaCheck as $key => $infoFilter) {
532 foreach ($infoFilter as $entity => $dataToCheck) {
6a488035
TO
533 $this->open($mailingReportUrl);
534 if ($entity == "report") {
d317a853 535 $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[1][text()='Report']");
0db6c3e1
TO
536 }
537 else {
d317a853 538 $this->clickLink("xpath=//fieldset/legend[text()='Delivery Summary']/../table//tr[td/a[text()='{$key}']]/descendant::td[3]/span/a[2][text()='Advanced Search']");
6a488035 539 }
2241036a 540 $this->_verifyCriteria($key, $dataToCheck, $entity);
6a488035
TO
541 }
542 }
543 }
e8743663 544
4cbe18b8
EM
545 /**
546 * @param $summaryInfo
547 * @param $dataToCheck
548 * @param $entity
549 */
00be9182 550 public function _verifyCriteria($summaryInfo, $dataToCheck, $entity) {
22e263ad 551 foreach ($dataToCheck as $key => $value) {
6a488035
TO
552 if ($entity == 'report') {
553 if ($key == 'report_name') {
b812c745 554 $this->waitForTextPresent("{$value}");
6a488035
TO
555 continue;
556 }
6c6e6187 557 $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
558 }
559 else {
b812c745 560 $this->waitForTextPresent("Advanced Search");
6a488035
TO
561 $assertedValue = $this->isElementPresent("xpath=//div[@class='crm-results-block']//div[@class='qill'][contains(text(),'{$key} {$value}')]");
562 if (!$assertedValue) {
563 $assertedValue = $this->isTextPresent("{$key} {$value}");
564 }
6c6e6187 565 $this->assertTrue($assertedValue, "Criteria check for {$key} failed for Advance Search for {$summaryInfo}");
6a488035
TO
566 }
567 }
e8743663 568 }
96025800 569
42daf119 570}