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 CreateProject extends FForge_SeleniumTestCase
49 // Simple creation of a project by the admin user and
50 // approval of the creation just after.
51 // After creation, project is visible on the main page.
52 function testSimpleCreate()
55 $this->login (FORGE_ADMIN_USERNAME);
56 $this->click("link=My Page");
57 $this->waitForPageToLoad("30000");
58 $this->click("link=Register Project");
59 $this->waitForPageToLoad("30000");
60 $this->type("full_name", "ProjectA");
61 $this->type("purpose", "This is a simple description for ProjectA");
62 $this->type("//textarea[@name='description']", "This is the public description for ProjectA.");
63 $this->type("unix_name", "projecta");
64 $this->click("//input[@name='scm' and @value='scmsvn']");
65 $this->assertTrue($this->isElementPresent("//select[@name='built_from_template']"));
66 $this->click("submit");
67 $this->waitForPageToLoad("30000");
68 $this->assertTrue($this->isTextPresent("Your project has been submitted"));
69 $this->assertTrue($this->isTextPresent("you will receive notification of their decision and further instructions"));
70 $this->click("link=Site Admin");
71 $this->waitForPageToLoad("30000");
72 $this->click("link=Pending projects (new project approval)");
73 $this->waitForPageToLoad("30000");
74 $this->click("document.forms['approve.projecta'].submit");
75 $this->waitForPageToLoad("60000");
76 $this->click("link=Home");
77 $this->waitForPageToLoad("30000");
78 $this->assertTrue($this->isTextPresent("ProjectA"));
79 $this->click("link=ProjectA");
80 $this->waitForPageToLoad("30000");
81 $this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
82 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
85 function testCharsCreateTestCase()
87 $this->login(FORGE_ADMIN_USERNAME);
88 $this->click("link=My Page");
89 $this->waitForPageToLoad("30000");
90 $this->click("link=Register Project");
91 $this->waitForPageToLoad("30000");
92 $this->type("full_name", "Project ' & B");
93 $this->type("purpose", "This is a & été simple description for project B");
94 $this->type("//textarea[@name='description']", "This is & été the public description for project B.");
95 $this->type("unix_name", "projectb");
96 $this->click("//input[@name='scm' and @value='scmsvn']");
97 $this->click("submit");
98 $this->waitForPageToLoad("30000");
99 $this->assertTrue($this->isTextPresent("Your project has been submitted"));
100 $this->assertTrue($this->isTextPresent("you will receive notification of their decision and further instructions"));
101 $this->click("link=Site Admin");
102 $this->waitForPageToLoad("30000");
103 $this->click("link=Pending projects (new project approval)");
104 $this->waitForPageToLoad("30000");
105 $this->click("document.forms['approve.projectb'].submit");
106 $this->waitForPageToLoad("60000");
107 $this->click("link=Home");
108 $this->waitForPageToLoad("30000");
109 $this->assertTrue($this->isTextPresent("Project ' & B"));
110 $this->click("link=Project ' & B");
111 $this->waitForPageToLoad("30000");
112 $this->assertTrue($this->isTextPresent("This is & été the public description for project B."));
114 $this->click("link=Projects");
115 $this->waitForPageToLoad("30000");
116 $this->click("link=Project Tree");
117 $this->waitForPageToLoad("30000");
118 $this->click("link=Project List");
119 $this->waitForPageToLoad("30000");
120 $this->assertTrue($this->isTextPresent("Project ' & B - This is & été the public description for project B."));
121 $this->click("link=My Page");
122 $this->waitForPageToLoad("30000");
123 $this->assertFalse($this->isTextPresent("Project ' & B"));
126 function testHighLevelFunctions()
128 // Test our high-level functions (testing the test-suite)
129 $this->createProject ('ProjectB');
130 $this->click("link=Home");
131 $this->waitForPageToLoad("30000");
132 $this->assertTrue($this->isTextPresent("ProjectB"));
133 $this->click("link=ProjectB");
134 $this->waitForPageToLoad("30000");
135 $this->assertTrue($this->isTextPresent("This is the public description for ProjectB."));
136 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
137 $this->gotoProject ('ProjectB');
138 $this->assertTrue($this->isTextPresent("This is the public description for ProjectB."));
139 $this->createAndGoto ('ProjectC');
140 $this->assertTrue($this->isTextPresent("This is the public description for ProjectC."));
142 $this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
145 function testTemplateProject()
147 $this->populateStandardTemplate('trackers');
149 $this->open( ROOT . '/projects/tmpl') ;
150 $this->waitForPageToLoad("30000");
152 $this->click("link=Admin");
153 $this->waitForPageToLoad("30000");
154 $this->click("link=Tools");
155 $this->waitForPageToLoad("30000");
156 $this->click("link=Trackers Admin");
157 $this->waitForPageToLoad("30000");
158 $this->type("name", "Local tracker for UNIXNAME");
159 $this->type("//input[@name='description']", "Tracker for PUBLICNAME (UNIXNAME)");
160 $this->click("post_changes");
161 $this->waitForPageToLoad("30000");
162 $this->assertTrue($this->isTextPresent("Tracker created successfully"));
165 $this->assertTrue($this->isElementPresent("//a[.='Tracker']"));
166 $this->assertTrue($this->isElementPresent("//a[.='Forums']"));
167 $this->assertTrue($this->isElementPresent("//a[.='Tasks']"));
168 $this->click("link=Tracker");
169 $this->waitForPageToLoad("30000");
170 $this->assertTrue($this->isTextPresent("Tracker for ProjectA (projecta)"));
172 // Test for fusionforge.org bug #245
173 $this->open( ROOT . '/projects/tmpl') ;
174 $this->waitForPageToLoad("30000");
176 $this->click("link=Admin");
177 $this->waitForPageToLoad("30000");
178 $this->click("link=Tools");
179 $this->waitForPageToLoad("30000");
180 $this->uncheck("//input[@name='use_tracker']") ;
181 $this->click("submit");
182 $this->waitForPageToLoad("30000");
184 $this->createAndGoto('ProjectB');
187 function testEmptyProject()
189 // Create an empty project despite the template being full
190 $this->populateStandardTemplate('all');
192 $this->click("link=My Page");
193 $this->waitForPageToLoad("30000");
194 $this->click("link=Register Project");
195 $this->waitForPageToLoad("30000");
196 $this->assertTrue($this->isElementPresent("//select[@name='built_from_template']"));
197 $this->type("full_name", "ProjectA");
198 $this->type("purpose", "This is a simple description for ProjectA");
199 $this->type("//textarea[@name='description']", "This is the public description for ProjectA.");
200 $this->type("unix_name", "projecta");
201 $this->select("//select[@name='built_from_template']", "label=Start from empty project");
202 $this->click("//input[@name='scm' and @value='scmsvn']");
203 $this->click("submit");
204 $this->waitForPageToLoad("30000");
205 $this->assertTrue($this->isTextPresent("Your project has been submitted"));
206 $this->assertTrue($this->isTextPresent("you will receive notification of their decision and further instructions"));
207 $this->click("link=Site Admin");
208 $this->waitForPageToLoad("30000");
209 $this->click("link=Pending projects (new project approval)");
210 $this->waitForPageToLoad("30000");
211 $this->click("document.forms['approve.projecta'].submit");
212 $this->waitForPageToLoad("60000");
213 $this->click("link=Home");
214 $this->waitForPageToLoad("30000");
215 $this->assertTrue($this->isTextPresent("ProjectA"));
216 $this->click("link=ProjectA");
217 $this->waitForPageToLoad("30000");
218 $this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
219 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
220 $this->assertFalse($this->isElementPresent("//a[.='Tracker']"));
221 $this->assertFalse($this->isElementPresent("//a[.='Forums']"));
222 $this->assertFalse($this->isElementPresent("//a[.='Tasks']"));
225 // Test removal of project.
226 function testRemoveProject()
228 $this->login(FORGE_ADMIN_USERNAME);
230 // Create project as a different user
231 // Non-regression test for Adacore ticket K720-005
232 $this->createUser('toto');
234 $this->click("link=Site Admin");
235 $this->waitForPageToLoad("30000");
236 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Forge administrators") ;
237 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
238 $this->waitForPageToLoad("30000");
239 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
240 $this->click ("//input[@value='Add User']") ;
241 $this->waitForPageToLoad("30000");
242 $this->assertTrue($this->isTextPresent("toto Lastname"));
244 $this->registerProject('testal1','toto');
245 $this->approveProject('testal1',FORGE_ADMIN_USERNAME);
247 $this->click("link=Site Admin");
248 $this->waitForPageToLoad("30000");
249 $this->click("link=Display Full Project List/Edit Projects");
250 $this->waitForPageToLoad("30000");
251 $this->click("link=testal1");
252 $this->waitForPageToLoad("30000");
253 $this->click("link=Permanently Delete Project");
254 $this->waitForPageToLoad("30000");
255 $this->click("sure");
256 $this->click("reallysure");
257 $this->click("reallyreallysure");
258 $this->click("submit");
259 $this->waitForPageToLoad("30000");
260 $this->click("link=Home");
261 $this->waitForPageToLoad("30000");
262 $this->assertFalse($this->isTextPresent("testal1"));
268 // c-file-style: "bsd"