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