(NFC) Update version headers in `tests/`
[civicrm-core.git] / tests / phpunit / WebTest / Mailing / AddNewMailingComponentTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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
29 /**
30 * Class WebTest_Mailing_AddNewMailingComponentTest
31 */
32 class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testHeaderAdd() {
39 $this->webtestLogin();
40
41 $this->openCiviPage("admin/component", "action=add&reset=1");
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.
69 $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
70
71 // Verify text.
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");
73 }
74
75 public function testFooterAdd() {
76 $this->webtestLogin();
77
78 $this->openCiviPage("admin/component", "action=add&reset=1");
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.
106 $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
107
108 // Verify text.
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");
110 }
111
112 public function testAutomatedAdd() {
113 $this->webtestLogin();
114
115 $this->openCiviPage("admin/component", "action=add&reset=1");
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.
143 $this->waitForText('crm-notification-container', "The mailing component '$componentName' has been saved.");
144
145 // Verify text
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");
147 }
148
149 }