Merge pull request #324 from pradpnayak/CRM-12275
[civicrm-core.git] / tests / phpunit / WebTest / Contact / TaskActionSendMassMailing.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25*/
26
6a488035
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Contact_TaskActionSendMassMailing extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testSelectedContacts() {
6a488035
TO
35 $this->webtestLogin();
36
225a8648 37 // make group
6a488035 38 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
225a8648 39 $this->WebtestAddGroup($groupName);
6a488035
TO
40
41 // Use class names for menu items since li array can change based on which components are enabled
42 $this->click("css=ul#civicrm-menu li.crm-Search");
225a8648 43 $this->clickLink("css=ul#civicrm-menu li.crm-Advanced_Search a", "email");
6a488035 44
6a488035
TO
45 $this->click("_qf_Advanced_refresh");
46 $this->waitForPageToLoad($this->getTimeoutMsec());
47
6a488035
TO
48 // Click "check all" box and act on "Add to group" action
49 $this->click("//form[@id='Advanced']/div[3]/div/div[2]/table/thead/tr/th[1]/input");
50 $this->select("task", "label=Schedule/Send a Mass Mailing");
51 $this->click("Go");
52 $this->waitForPageToLoad($this->getTimeoutMsec());
53
54 //-------select recipients----------
55
56 $mailingName = 'Selected Contact Mailing Test ' . substr(sha1(rand()), 0, 7);
57
58 $this->waitForElementPresent("name");
59 $this->type("name", "$mailingName");
60 $this->select("baseGroup", "label=$groupName");
61 $this->click("//option[@value='4']");
62 $this->click("_qf_Group_next");
63
64 //--------track and respond----------
65
66 $this->waitForElementPresent("_qf_Settings_next");
67
68 // check for default settings options
69 $this->assertChecked("url_tracking");
70 $this->assertChecked("open_tracking");
71
72 $this->click("_qf_Settings_next");
73
74 //--------Mailing content------------
75 // fill subject for mailing
76 $this->waitForElementPresent("subject");
77 $this->type("subject", "Test subject {$mailingName} for Webtest");
78
79 // check for default option enabled
80 $this->assertChecked("CIVICRM_QFID_1_4");
81
82 // HTML format message
83 $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest.";
84 $this->fillRichTextField("html_message", $HTMLMessage);
85
86 // Open Plain-text Format pane and type text format msg
87 $this->click("//fieldset[@id='compose_id']/div[2]/div[1]");
88 $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest.");
89
90 // select default header and footer ( with label )
91 $this->select("header_id", "label=Mailing Header");
92 $this->select("footer_id", "label=Mailing Footer");
93 $this->click("_qf_Upload_upload");
94
95 $this->waitForElementPresent("_qf_Test_next");
96 $this->click("_qf_Test_next");
97
98 //----------Schedule or Send------------
99
100 $this->waitForElementPresent("_qf_Schedule_next");
101
102 $this->assertChecked("now");
103
104 $this->click("_qf_Schedule_next");
105 $this->waitForPageToLoad($this->getTimeoutMsec());
106
107 //----------end New Mailing-------------
108
109 //check redirected page to Scheduled and Sent Mailings and verify for mailing name
110 $this->assertTrue($this->isTextPresent("Scheduled and Sent Mailings"));
111 $this->assertTrue($this->isTextPresent("$mailingName"));
112
113 //--------- mail delivery verification---------
114
115 // test undelivered report
116
117 // click report link of created mailing
118 $this->click("xpath=//table//tbody/tr[td[1]/text()='$mailingName']/descendant::a[text()='Report']");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
120
121 // verify undelivered status message
122 $this->assertTrue($this->isTextPresent("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."));
123
124 // directly send schedule mailing -- not working right now
071a6d2e 125 $this->openCiviPage("mailing/queue", "reset=1");
6a488035
TO
126
127 //click report link of created mailing
128 $this->click("xpath=//table//tbody/tr[td[1]/text()='$mailingName']/descendant::a[text()='Report']");
129 $this->waitForPageToLoad($this->getTimeoutMsec());
130 }
131}
132