3 * Copyright (C) 2008 Alain Peyrat <aljeux@free.fr>
4 * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
6 * This file is part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2 of the License,
11 * or (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * Standard Alcatel-Lucent disclaimer for contributing to open source
26 * "The test suite ("Contribution") has not been tested and/or
27 * validated for release as or in products, combinations with products or
28 * other commercial use. Any use of the Contribution is entirely made at
29 * the user's own responsibility and the user can not rely on any features,
30 * functionalities or performances Alcatel-Lucent has attributed to the
33 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
34 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
35 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
36 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
37 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
38 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
39 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
40 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
41 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
45 require_once dirname(dirname(__FILE__)).'/Testing/SeleniumGforge.php';
47 class CreateForum extends FForge_SeleniumTestCase
49 function testSimplePost()
51 // Create the first message (Message1/Text1).
52 $this->populateStandardTemplate('forums');
54 $this->clickAndWait("link=Forums");
55 $this->assertFalse($this->isTextPresent("Permission denied."));
56 $this->assertTrue($this->isTextPresent("open-discussion"));
57 $this->click("link=open-discussion");
58 $this->waitForPageToLoad("30000");
59 $this->click("link=Start New Thread");
60 $this->waitForPageToLoad("30000");
61 $this->type("subject", "Message1");
62 $this->type("body", "Text1");
63 $this->click("submit");
64 $this->waitForPageToLoad("30000");
65 $this->assertTrue($this->isTextPresent("Message Posted Successfully"));
66 $this->click("link=Forums");
67 $this->waitForPageToLoad("30000");
68 $this->assertTrue($this->isTextPresent("open-discussion"));
69 $this->click("link=open-discussion");
70 $this->waitForPageToLoad("30000");
71 $this->assertTrue($this->isTextPresent("Message1"));
75 * Simulate a click on the link from a mail.
76 * As the forum is private, the users should be
77 * redirected to the login prompt saying that he has
78 * to login to get access to the message. Once logged,
79 * he should be redirected to the given forum.
81 function testSimpleAccessWhenPrivate()
83 $this->populateStandardTemplate('forums');
86 $this->open( ROOT.'/forum/message.php?msg_id=6' );
87 $this->waitForPageToLoad("30000");
88 $this->assertTrue($this->isTextPresent("Welcome to developers"));
91 $this->open( ROOT.'/forum/message.php?msg_id=6' );
92 $this->waitForPageToLoad("30000");
93 $this->assertTrue($this->isLoginRequired());
94 $this->triggeredLogin(FORGE_ADMIN_USERNAME);
95 $this->assertTrue($this->isTextPresent("Welcome to developers"));
99 * Simulate a user non logged that will reply
100 * to a message in a forum. He will be redirected
101 * to the login page, then will reply and then
102 * we check that his reply is present in the thread.
104 function testReplyToMessage()
106 $this->populateStandardTemplate('forums');
110 $this->gotoProject('ProjectA');
111 $this->clickAndWait("link=Forums");
112 $this->clickAndWait("link=open-discussion");
113 $this->clickAndWait("link=Welcome to open-discussion");
114 $this->click("link=[ reply ]");
115 $this->waitForPageToLoad("30000");
116 $this->assertTrue($this->isLoginRequired());
117 $this->triggeredLogin(FORGE_ADMIN_USERNAME);
118 $this->type("body", "Here is my 19823 reply");
119 $this->clickAndWait("submit");
120 $this->assertTextPresent("Message Posted Successfully");
121 $this->click("link=Welcome to open-discussion");
122 $this->waitForPageToLoad("30000");
123 $this->assertTextPresent("Here is my 19823 reply");
128 * Verify that it is impossible to use name already used by a mailing list
130 function testEmailAddressNotAlreadyUsed() {
131 $this->populateStandardTemplate('forums');
133 $this->click("link=Mailing Lists");
134 $this->waitForPageToLoad("30000");
135 $this->click("//body//div[@id='maindiv']/p[1]/strong/a[2]");
136 $this->waitForPageToLoad("30000");
137 $this->click("link=Add Mailing List");
138 $this->waitForPageToLoad("30000");
139 $this->type("list_name", "toto");
140 $this->type("//input[@name='description']", "Toto mailing list");
141 $this->click("submit");
142 $this->waitForPageToLoad("30000");
143 $this->assertTrue($this->isTextPresent("List Added"));
144 $this->click("link=Forums");
145 $this->waitForPageToLoad("30000");
146 $this->click("//body//div[@id='maindiv']/p[1]/strong/a[2]");
147 $this->waitForPageToLoad("30000");
148 $this->click("link=Add Forum");
149 $this->waitForPageToLoad("30000");
150 $this->type("forum_name", "toto");
151 $this->type("//input[@name='description']", "Toto forum");
152 $this->click("submit");
153 $this->waitForPageToLoad("30000");
154 $this->assertTrue($this->isTextPresent("Error: a mailing list with the same email address already exists"));
157 function testHtmlFiltering()
159 // Create the first message (Message1/Text1).
160 $this->populateStandardTemplate('forums');
162 $this->clickAndWait("link=Forums");
163 $this->assertFalse($this->isTextPresent("Permission denied."));
164 $this->assertTextPresent("open-discussion");
165 $this->clickAndWait("link=open-discussion");
166 $this->clickAndWait("link=Start New Thread");
167 $this->type("subject", "Message1");
168 $this->type("body", "Text1 <script>Hacker inside</script> done");
169 $this->clickAndWait("submit");
170 $this->assertTextPresent("Message Posted Successfully");
171 $this->clickAndWait("link=Forums");
172 $this->assertTextPresent("open-discussion");
173 $this->clickAndWait("link=open-discussion");
174 $this->assertTextPresent("Message1");
175 $this->assertFalse($this->isTextPresent("Hacker inside"));
176 $this->assertFalse($this->isTextPresent("Text1 done"));
182 // c-file-style: "bsd"