3 * Copyright (C) 2008 Alain Peyrat <aljeux@free.fr>
4 * Copyright (C) 2009 Alain Peyrat, Alcatel-Lucent
5 * Copyright 2013, Franck Villaume - TrivialDev
7 * This file is part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2 of the License,
12 * or (at your option) any later version.
14 * FusionForge 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. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 * Standard Alcatel-Lucent disclaimer for contributing to open source
27 * "The test suite ("Contribution") has not been tested and/or
28 * validated for release as or in products, combinations with products or
29 * other commercial use. Any use of the Contribution is entirely made at
30 * the user's own responsibility and the user can not rely on any features,
31 * functionalities or performances Alcatel-Lucent has attributed to the
34 * THE CONTRIBUTION BY ALCATEL-LUCENT IS PROVIDED AS IS, WITHOUT WARRANTY
35 * OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
36 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, COMPLIANCE,
37 * NON-INTERFERENCE AND/OR INTERWORKING WITH THE SOFTWARE TO WHICH THE
38 * CONTRIBUTION HAS BEEN MADE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
39 * ALCATEL-LUCENT BE LIABLE FOR ANY DAMAGES OR OTHER LIABLITY, WHETHER IN
40 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
41 * CONTRIBUTION OR THE USE OR OTHER DEALINGS IN THE CONTRIBUTION, WHETHER
42 * TOGETHER WITH THE SOFTWARE TO WHICH THE CONTRIBUTION RELATES OR ON A STAND
46 require_once dirname(dirname(__FILE__)).'/Testing/SeleniumGforge.php';
48 class CreateProject extends FForge_SeleniumTestCase
50 // Simple creation of a project by the admin user.
51 // approval is automatic since project is created bu admin user.
52 // After creation, project is visible on the main page.
53 function testSimpleCreate()
56 $this->login (FORGE_ADMIN_USERNAME);
57 $this->click("link=My Page");
58 $this->waitForPageToLoad("30000");
59 $this->click("link=Register Project");
60 $this->waitForPageToLoad("30000");
61 $this->type("full_name", "ProjectA");
62 $this->type("purpose", "This is a simple description for ProjectA");
63 $this->type("//textarea[@name='description']", "This is the public description for ProjectA.");
64 $this->type("unix_name", "projecta");
65 $this->click("//input[@name='scm' and @value='scmsvn']");
66 $this->assertTrue($this->isElementPresent("//select[@name='built_from_template']"));
67 $this->click("submit");
68 $this->waitForPageToLoad("30000");
69 $this->assertTrue($this->isTextPresent("Your project has been automatically approved"));
70 $this->click("link=Home");
71 $this->waitForPageToLoad("30000");
72 $this->assertTrue($this->isTextPresent("ProjectA"));
73 $this->click("link=ProjectA");
74 $this->waitForPageToLoad("30000");
75 $this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
76 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
79 function testCharsCreateTestCase()
81 $this->login(FORGE_ADMIN_USERNAME);
82 $this->click("link=My Page");
83 $this->waitForPageToLoad("30000");
84 $this->click("link=Register Project");
85 $this->waitForPageToLoad("30000");
86 $this->type("full_name", "Project ' & B");
87 $this->type("purpose", "This is a & été simple description for project B");
88 $this->type("//textarea[@name='description']", "This is & été the public description for project B.");
89 $this->type("unix_name", "projectb");
90 $this->click("//input[@name='scm' and @value='scmsvn']");
91 $this->click("submit");
92 $this->waitForPageToLoad("30000");
93 $this->assertTrue($this->isTextPresent("Your project has been automatically approved"));
94 $this->click("link=Home");
95 $this->waitForPageToLoad("30000");
96 $this->assertTrue($this->isTextPresent("Project ' & B"));
97 $this->click("link=Project ' & B");
98 $this->waitForPageToLoad("30000");
99 $this->assertTrue($this->isTextPresent("This is & été the public description for project B."));
101 $this->click("link=Projects");
102 $this->waitForPageToLoad("30000");
103 $this->click("link=Project Tree");
104 $this->waitForPageToLoad("30000");
105 $this->click("link=Project List");
106 $this->waitForPageToLoad("30000");
107 $this->assertTrue($this->isTextPresent("Project ' & B - This is & été the public description for project B."));
108 $this->click("link=My Page");
109 $this->waitForPageToLoad("30000");
110 $this->assertFalse($this->isTextPresent("Project ' & B"));
113 function testHighLevelFunctions()
115 // Test our high-level functions (testing the test-suite)
116 $this->createProject ('ProjectB');
117 $this->click("link=Home");
118 $this->waitForPageToLoad("30000");
119 $this->assertTrue($this->isTextPresent("ProjectB"));
120 $this->click("link=ProjectB");
121 $this->waitForPageToLoad("30000");
122 $this->assertTrue($this->isTextPresent("This is the public description for ProjectB."));
123 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
124 $this->gotoProject ('ProjectB');
125 $this->assertTrue($this->isTextPresent("This is the public description for ProjectB."));
126 $this->createAndGoto ('ProjectC');
127 $this->assertTrue($this->isTextPresent("This is the public description for ProjectC."));
129 $this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
132 function testTemplateProject()
134 $this->populateStandardTemplate('trackers');
136 $this->open( ROOT . '/projects/tmpl') ;
137 $this->waitForPageToLoad("30000");
139 $this->click("link=Admin");
140 $this->waitForPageToLoad("30000");
141 $this->click("link=Tools");
142 $this->waitForPageToLoad("30000");
143 $this->click("link=Trackers Admin");
144 $this->waitForPageToLoad("30000");
145 $this->type("name", "Local tracker for UNIXNAME");
146 $this->type("//input[@name='description']", "Tracker for PUBLICNAME (UNIXNAME)");
147 $this->click("post_changes");
148 $this->waitForPageToLoad("30000");
149 $this->assertTrue($this->isTextPresent("Tracker created successfully"));
152 $this->assertTrue($this->isElementPresent("//a[.='Tracker']"));
153 $this->assertTrue($this->isElementPresent("//a[.='Forums']"));
154 $this->assertTrue($this->isElementPresent("//a[.='Tasks']"));
155 $this->click("link=Tracker");
156 $this->waitForPageToLoad("30000");
157 $this->assertTrue($this->isTextPresent("Tracker for ProjectA (projecta)"));
159 // Test for fusionforge.org bug #245
160 $this->open( ROOT . '/projects/tmpl') ;
161 $this->waitForPageToLoad("30000");
163 $this->click("link=Admin");
164 $this->waitForPageToLoad("30000");
165 $this->click("link=Tools");
166 $this->waitForPageToLoad("30000");
167 $this->uncheck("//input[@name='use_tracker']") ;
168 $this->click("submit");
169 $this->waitForPageToLoad("30000");
171 $this->createAndGoto('ProjectB');
174 function testEmptyProject()
176 // Create an empty project despite the template being full
177 $this->populateStandardTemplate('all');
179 $this->click("link=My Page");
180 $this->waitForPageToLoad("30000");
181 $this->click("link=Register Project");
182 $this->waitForPageToLoad("30000");
183 $this->assertTrue($this->isElementPresent("//select[@name='built_from_template']"));
184 $this->type("full_name", "ProjectA");
185 $this->type("purpose", "This is a simple description for ProjectA");
186 $this->type("//textarea[@name='description']", "This is the public description for ProjectA.");
187 $this->type("unix_name", "projecta");
188 $this->select("//select[@name='built_from_template']", "label=Start from empty project");
189 $this->click("//input[@name='scm' and @value='scmsvn']");
190 $this->click("submit");
191 $this->waitForPageToLoad("30000");
192 $this->assertTrue($this->isTextPresent("Your project has been automatically approved"));
193 $this->click("link=Home");
194 $this->waitForPageToLoad("30000");
195 $this->assertTrue($this->isTextPresent("ProjectA"));
196 $this->click("link=ProjectA");
197 $this->waitForPageToLoad("30000");
198 $this->assertTrue($this->isTextPresent("This is the public description for ProjectA."));
199 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
200 $this->assertFalse($this->isElementPresent("//a[.='Tracker']"));
201 $this->assertFalse($this->isElementPresent("//a[.='Forums']"));
202 $this->assertFalse($this->isElementPresent("//a[.='Tasks']"));
205 // Test removal of project.
206 function testRemoveProject()
208 $this->login(FORGE_ADMIN_USERNAME);
210 // Create project as a different user
211 // Non-regression test for Adacore ticket K720-005
212 $this->createUser('toto');
214 $this->click("link=Site Admin");
215 $this->waitForPageToLoad("30000");
216 $this->select ("//form[contains(@action,'globalroleedit.php')]//select[@name='role_id']", "label=Forge administrators") ;
217 $this->click ("//form[contains(@action,'globalroleedit.php')]//input[@value='Edit Role']") ;
218 $this->waitForPageToLoad("30000");
219 $this->type ("//form[contains(@action,'globalroleedit.php')]//input[@name='form_unix_name']", "toto") ;
220 $this->click ("//input[@value='Add User']") ;
221 $this->waitForPageToLoad("30000");
222 $this->assertTrue($this->isTextPresent("toto Lastname"));
224 $this->registerProject('testal1','toto');
226 $this->click("link=Site Admin");
227 $this->waitForPageToLoad("30000");
228 $this->click("link=Display Full Project List/Edit Projects");
229 $this->waitForPageToLoad("30000");
230 $this->click("link=testal1");
231 $this->waitForPageToLoad("30000");
232 $this->click("link=Permanently Delete Project");
233 $this->waitForPageToLoad("30000");
234 $this->click("sure");
235 $this->click("reallysure");
236 $this->click("reallyreallysure");
237 $this->click("submit");
238 $this->waitForPageToLoad("30000");
239 $this->click("link=Home");
240 $this->waitForPageToLoad("30000");
241 $this->assertFalse($this->isTextPresent("testal1"));
247 // c-file-style: "bsd"