Commit | Line | Data |
---|---|---|
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Mailing_AddMessageTemplateTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
4cbe18b8 EM |
38 | /** |
39 | * @param bool $useTokens | |
40 | * @param null $msgTitle | |
41 | */ | |
00be9182 | 42 | public function testTemplateAdd($useTokens = FALSE, $msgTitle = NULL) { |
6a488035 TO |
43 | $this->webtestLogin(); |
44 | ||
6a488035 TO |
45 | $this->openCiviPage("admin/messageTemplates/add", "action=add&reset=1"); |
46 | ||
80ba1424 | 47 | $this->waitForElementPresent("_qf_MessageTemplates_cancel-bottom"); |
6a488035 TO |
48 | // Fill message title. |
49 | if (!$msgTitle) { | |
50 | $msgTitle = 'msg_' . substr(sha1(rand()), 0, 7); | |
51 | } | |
52 | $this->type("msg_title", $msgTitle); | |
53 | if ($useTokens) { | |
54 | //Add Tokens | |
b4742465 | 55 | $this->select2("msg_subject", "Display Name"); |
56 | $this->select2("msg_subject", "Contact Type"); | |
57 | $this->select2("xpath=//*[contains(@data-field,'msg_text')]/../div/a", "Display Name", FALSE, TRUE); | |
58 | $this->select2("xpath=//*[contains(@data-field,'msg_text')]/../div/a", "Contact Type", FALSE, TRUE); | |
59 | $this->select2("xpath=//*[contains(@data-field,'html_message')]/../div/a", "Display Name", FALSE, TRUE); | |
60 | $this->select2("xpath=//*[contains(@data-field,'html_message')]/../div/a", "Contact Type", FALSE, TRUE); | |
6a488035 TO |
61 | } |
62 | else { | |
63 | // Fill message subject. | |
64 | $msgSubject = "This is subject for message"; | |
65 | $this->type("msg_subject", $msgSubject); | |
66 | ||
67 | // Fill text message. | |
68 | $txtMsg = "This is text message"; | |
69 | $this->type("msg_text", $txtMsg); | |
70 | ||
71 | // Fill html message. | |
72 | $htmlMsg = "This is HTML message"; | |
73 | $this->type("msg_html", $htmlMsg); | |
74 | } | |
75 | // Clicking save. | |
76 | $this->click("_qf_MessageTemplates_next"); | |
77 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
78 | ||
79 | // Is status message correct | |
6c5f7368 | 80 | $this->waitForText('crm-notification-container', "The Message Template '$msgTitle' has been saved."); |
6a488035 TO |
81 | |
82 | // Verify text. | |
933ee1e4 | 83 | $this->assertTrue($this->isElementPresent("xpath=id('user')//div//div/table[@class='display dataTable no-footer']/tbody//tr/td[1][contains(text(), '$msgTitle')]"), |
3fb9aed9 | 84 | 'Message Template Title not found!'); |
6a488035 | 85 | if (!$useTokens) { |
933ee1e4 | 86 | $this->assertTrue($this->isElementPresent("xpath=id('user')//div//div/table[@class='display dataTable no-footer']/tbody//tr/td[2][contains(text(), '$msgSubject')]"), |
3fb9aed9 | 87 | 'Message Subject not found!'); |
6a488035 TO |
88 | } |
89 | } | |
90 | ||
00be9182 | 91 | public function testAddMailingWithMessageTemplate() { |
a6f95222 | 92 | $this->markTestSkipped('Skipping for now as it works fine locally.'); |
6a488035 TO |
93 | // Call the above test to set up our environment |
94 | $msgTitle = 'msg_' . substr(sha1(rand()), 0, 7); | |
95 | $this->testTemplateAdd(TRUE, $msgTitle); | |
96 | ||
97 | // create new mailing group | |
98 | $groupName = $this->WebtestAddGroup(); | |
99 | ||
100 | //Create new contact and add to mailing Group | |
101 | $firstName = substr(sha1(rand()), 0, 7); | |
102 | $this->webtestAddContact($firstName, "Mailson", "mailino$firstName@mailson.co.in"); | |
103 | $this->click("css=li#tab_group a"); | |
104 | $this->waitForElementPresent("_qf_GroupContact_next"); | |
105 | $this->select("group_id", "$groupName"); | |
106 | $this->click("_qf_GroupContact_next"); | |
107 | ||
108 | // configure default mail-box | |
5ff68892 | 109 | $this->setupDefaultMailbox(); |
6a488035 | 110 | |
03748831 | 111 | $this->openCiviPage("a/#/mailing/new"); |
112 | $this->waitForElementPresent("xpath=//input[@name='mailingName']"); | |
6a488035 TO |
113 | |
114 | // fill mailing name | |
115 | $mailingName = substr(sha1(rand()), 0, 7); | |
03748831 | 116 | $this->type("xpath=//input[@name='mailingName']", "Mailing $mailingName Webtest"); |
6a488035 TO |
117 | |
118 | // Add the test mailing group | |
03748831 | 119 | $this->select2("s2id_crmUiId_8", $groupName, TRUE); |
6a488035 TO |
120 | |
121 | // do check count for Recipient | |
03748831 | 122 | $this->waitForTextPresent("~1 recipient"); |
123 | $this->click("msg_template_id"); | |
124 | $this->select("msg_template_id", "label=$msgTitle"); | |
2198c6e5 WA |
125 | $this->waitForAjaxContent(); |
126 | $this->select2('s2id_autogen1', "Unsubscribe via web page"); | |
127 | $this->select2('s2id_autogen1', "Domain (organization) address"); | |
128 | $this->waitForAjaxContent(); | |
129 | $this->select2('s2id_autogen3', "Unsubscribe via web page"); | |
130 | $this->select2('s2id_autogen3', "Domain (organization) address"); | |
131 | $this->waitForAjaxContent(); | |
03748831 | 132 | $this->click("xpath=//div[@class='preview-popup']//a[text()='Preview as Plain Text']"); |
6a488035 TO |
133 | $this->click('subject'); |
134 | ||
03748831 | 135 | // check for default settings options |
f952d4f0 | 136 | $this->click('link=Tracking'); |
03748831 | 137 | $this->assertChecked("url_tracking"); |
138 | $this->assertChecked("open_tracking"); | |
139 | ||
6a488035 | 140 | // check for default header and footer ( with label ) |
f952d4f0 | 141 | $this->click('link=Header and Footer'); |
6a488035 TO |
142 | $this->select('header_id', "label=Mailing Header"); |
143 | $this->select('footer_id', "label=Mailing Footer"); | |
144 | ||
6a488035 | 145 | // click next |
03748831 | 146 | $this->click("xpath=//div[@class='crm-wizard-buttons']/button[text()='Next']"); |
6a488035 | 147 | |
03748831 | 148 | $this->assertChecked("xpath=//input[@id='schedule-send-now']"); |
149 | $this->waitForTextPresent("Mailing $mailingName Webtest"); | |
150 | $this->click("xpath=//div[@class='content']//a[text()='~1 recipient']"); | |
d50d5019 | 151 | $this->webtestVerifyTabularData(array("$firstName Mailson" => "mailino$firstName@mailson.co.in")); |
03748831 | 152 | $this->click("xpath=//button[@title='Close']"); |
153 | $this->waitForTextPresent("(Include: $groupName)"); | |
6a488035 TO |
154 | |
155 | // finally schedule the mail by clicking submit | |
03748831 | 156 | $this->click("xpath=//center/a/div[text()='Submit Mailing']"); |
6a488035 TO |
157 | |
158 | //check redirected page to Scheduled and Sent Mailings and verify for mailing name | |
03748831 | 159 | $this->waitForTextPresent("Find Mailings"); |
b4742465 | 160 | $this->isTextPresent("Mailing $mailingName Webtest"); |
6a488035 TO |
161 | $this->openCiviPage('mailing/queue', 'reset=1'); |
162 | ||
163 | // verify status | |
164 | $this->verifyText("xpath=id('Search')/table/tbody/tr[1]/td[2]", preg_quote("Complete")); | |
165 | ||
166 | //View Activity | |
167 | $this->openCiviPage('activity/search', "reset=1", "_qf_Search_refresh"); | |
168 | $this->type("sort_name", $firstName); | |
d50d5019 | 169 | $this->select("activity_type_id", "label=Bulk Email"); |
6a488035 | 170 | $this->click("_qf_Search_refresh"); |
74210507 RK |
171 | $this->waitForElementPresent("xpath=//form[@id='Search']/div[3]/div/div[2]/table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[1][text()='View']"); |
172 | $this->click("xpath=//form[@id='Search']/div[3]/div/div[2]/table[@class='selector row-highlight']/tbody/tr[2]/td[9]/span/a[1][text()='View']"); | |
173 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[2]"); | |
f75b8467 | 174 | $this->assertElementContainsText("xpath=//div[@class='help']", "Bulk Email Sent.", "Status message didn't show up after saving!"); |
6a488035 | 175 | } |
96025800 | 176 | |
42daf119 | 177 | } |