Commit | Line | Data |
---|---|---|
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 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Contact_TaskActionSendMassMailing extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testSelectedContacts() { | |
36 | $this->open($this->sboxPath); | |
37 | $this->webtestLogin(); | |
38 | ||
39 | // Go directly to the URL of the screen that you will be testing (New Group). | |
40 | $this->open($this->sboxPath . "civicrm/group/add&reset=1"); | |
41 | $this->waitForElementPresent("_qf_Edit_upload"); | |
42 | ||
43 | // make group name | |
44 | $groupName = 'group_' . substr(sha1(rand()), 0, 7); | |
45 | ||
46 | // fill group name | |
47 | $this->type("title", $groupName); | |
48 | ||
49 | // fill description | |
50 | $this->type("description", "New mailing group for Webtest"); | |
51 | ||
52 | // enable Mailing List | |
53 | $this->click("group_type[2]"); | |
54 | ||
55 | // select Visibility as Public Pages | |
56 | $this->select("visibility", "value=Public Pages"); | |
57 | ||
58 | // Clicking save. | |
59 | $this->click("_qf_Edit_upload"); | |
60 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
61 | ||
62 | // Use class names for menu items since li array can change based on which components are enabled | |
63 | $this->click("css=ul#civicrm-menu li.crm-Search"); | |
64 | $this->click("css=ul#civicrm-menu li.crm-Advanced_Search a"); | |
65 | ||
66 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
67 | $this->waitForElementPresent("email"); | |
68 | $this->click("_qf_Advanced_refresh"); | |
69 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
70 | ||
71 | ||
72 | // Click "check all" box and act on "Add to group" action | |
73 | $this->click("//form[@id='Advanced']/div[3]/div/div[2]/table/thead/tr/th[1]/input"); | |
74 | $this->select("task", "label=Schedule/Send a Mass Mailing"); | |
75 | $this->click("Go"); | |
76 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
77 | ||
78 | //-------select recipients---------- | |
79 | ||
80 | $mailingName = 'Selected Contact Mailing Test ' . substr(sha1(rand()), 0, 7); | |
81 | ||
82 | $this->waitForElementPresent("name"); | |
83 | $this->type("name", "$mailingName"); | |
84 | $this->select("baseGroup", "label=$groupName"); | |
85 | $this->click("//option[@value='4']"); | |
86 | $this->click("_qf_Group_next"); | |
87 | ||
88 | //--------track and respond---------- | |
89 | ||
90 | $this->waitForElementPresent("_qf_Settings_next"); | |
91 | ||
92 | // check for default settings options | |
93 | $this->assertChecked("url_tracking"); | |
94 | $this->assertChecked("open_tracking"); | |
95 | ||
96 | $this->click("_qf_Settings_next"); | |
97 | ||
98 | //--------Mailing content------------ | |
99 | // fill subject for mailing | |
100 | $this->waitForElementPresent("subject"); | |
101 | $this->type("subject", "Test subject {$mailingName} for Webtest"); | |
102 | ||
103 | // check for default option enabled | |
104 | $this->assertChecked("CIVICRM_QFID_1_4"); | |
105 | ||
106 | // HTML format message | |
107 | $HTMLMessage = "This is HTML formatted content for Mailing {$mailingName} Webtest."; | |
108 | $this->fillRichTextField("html_message", $HTMLMessage); | |
109 | ||
110 | // Open Plain-text Format pane and type text format msg | |
111 | $this->click("//fieldset[@id='compose_id']/div[2]/div[1]"); | |
112 | $this->type("text_message", "This is text formatted content for Mailing {$mailingName} Webtest."); | |
113 | ||
114 | // select default header and footer ( with label ) | |
115 | $this->select("header_id", "label=Mailing Header"); | |
116 | $this->select("footer_id", "label=Mailing Footer"); | |
117 | $this->click("_qf_Upload_upload"); | |
118 | ||
119 | $this->waitForElementPresent("_qf_Test_next"); | |
120 | $this->click("_qf_Test_next"); | |
121 | ||
122 | //----------Schedule or Send------------ | |
123 | ||
124 | $this->waitForElementPresent("_qf_Schedule_next"); | |
125 | ||
126 | $this->assertChecked("now"); | |
127 | ||
128 | $this->click("_qf_Schedule_next"); | |
129 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
130 | ||
131 | //----------end New Mailing------------- | |
132 | ||
133 | //check redirected page to Scheduled and Sent Mailings and verify for mailing name | |
134 | $this->assertTrue($this->isTextPresent("Scheduled and Sent Mailings")); | |
135 | $this->assertTrue($this->isTextPresent("$mailingName")); | |
136 | ||
137 | //--------- mail delivery verification--------- | |
138 | ||
139 | // test undelivered report | |
140 | ||
141 | // click report link of created mailing | |
142 | $this->click("xpath=//table//tbody/tr[td[1]/text()='$mailingName']/descendant::a[text()='Report']"); | |
143 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
144 | ||
145 | // verify undelivered status message | |
146 | $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.")); | |
147 | ||
148 | // directly send schedule mailing -- not working right now | |
149 | $this->open($this->sboxPath . "civicrm/mailing/queue&reset=1"); | |
150 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
151 | ||
152 | //click report link of created mailing | |
153 | $this->click("xpath=//table//tbody/tr[td[1]/text()='$mailingName']/descendant::a[text()='Report']"); | |
154 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
155 | } | |
156 | } | |
157 | ||
158 |