Merge pull request #9570 from colemanw/CRM-19773-report
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / AddNewMailingComponentTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
81621fee 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
15a4309a 6 | Copyright CiviCRM LLC (c) 2004-2017 |
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_AddNewMailingComponentTest
31 */
6a488035
TO
32class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
00be9182 38 public function testHeaderAdd() {
6a488035
TO
39 $this->webtestLogin();
40
3fb9aed9 41 $this->openCiviPage("admin/component", "action=add&reset=1");
6a488035
TO
42
43 // fill component name.
44 $componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
45 $this->type("name", $componentName);
46
47 // fill component type
48 $this->click("component_type");
49 $this->select("component_type", "value=Header");
50
51 // fill subject
52 $subject = "This is subject for New Mailing Component.";
53 $this->type("subject", $subject);
54
55 // fill text message
56 $txtMsg = "This is Header Text Message";
57 $this->type("body_text", $txtMsg);
58
59 // fill html message
60 $htmlMsg = "This is Header HTML Message";
61 $this->type("body_html", $htmlMsg);
62 $this->click("is_default");
63
64 // Clicking save.
65 $this->click("_qf_Component_next");
66 $this->waitForPageToLoad($this->getTimeoutMsec());
67
68 // Is status message correct.
6c5f7368 69 $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
6a488035
TO
70
71 // Verify text.
1b1cbb04 72 $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td/div[text()='{$componentName}']/../../td[2][text()='Header']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
6a488035
TO
73 }
74
00be9182 75 public function testFooterAdd() {
6a488035
TO
76 $this->webtestLogin();
77
3fb9aed9 78 $this->openCiviPage("admin/component", "action=add&reset=1");
6a488035
TO
79
80 // fill component name.
81 $componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
82 $this->type("name", $componentName);
83
84 // fill component type
85 $this->click("component_type");
86 $this->select("component_type", "value=Footer");
87
88 // fill subject
89 $subject = "This is subject for New Mailing Component.";
90 $this->type("subject", $subject);
91
92 // fill text message
93 $txtMsg = "This is Footer Text Message";
94 $this->type("body_text", $txtMsg);
95
96 // fill html message
97 $htmlMsg = "This is Footer HTML Message";
98 $this->type("body_html", $htmlMsg);
99 $this->click("is_default");
100
101 // Clicking save.
102 $this->click("_qf_Component_next");
103 $this->waitForPageToLoad($this->getTimeoutMsec());
104
105 // Is status message correct.
6c6e6187 106 $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
6a488035
TO
107
108 // Verify text.
1b1cbb04 109 $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td/div[text()='{$componentName}']/../../td[2][text()='Footer']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
6a488035
TO
110 }
111
00be9182 112 public function testAutomatedAdd() {
6a488035
TO
113 $this->webtestLogin();
114
3fb9aed9 115 $this->openCiviPage("admin/component", "action=add&reset=1");
6a488035
TO
116
117 // fill component name.
118 $componentName = 'ComponentName_' . substr(sha1(rand()), 0, 7);
119 $this->type("name", $componentName);
120
121 // fill component type
122 $this->click("component_type");
123 $this->select("component_type", "value=Reply");
124
125 // fill subject
126 $subject = "This is subject for New Mailing Component.";
127 $this->type("subject", $subject);
128
129 // fill text message
130 $txtMsg = "This is Automated Text Message";
131 $this->type("body_text", $txtMsg);
132
133 // fill html message
134 $htmlMsg = "This is Automated HTML Message";
135 $this->type("body_html", $htmlMsg);
136 $this->click("is_default");
137
138 // Clicking save.
139 $this->click("_qf_Component_next");
140 $this->waitForPageToLoad($this->getTimeoutMsec());
141
142 // Is status message correct.
6c6e6187 143 $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
6a488035
TO
144
145 // Verify text
1b1cbb04 146 $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td/div[text()='{$componentName}']/../../td[2][text()='Reply']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details");
6a488035 147 }
96025800 148
42daf119 149}