3 * Copyright (C) 2007-2008 Alain Peyrat <aljeux at free dot 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
19 * along with FusionForge; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
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 'func/config.php';
47 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
49 class FForge_SeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase
51 protected function setUp()
53 if (defined('DB_INIT_CMD')) {
54 // Reload a fresh database before running this test suite.
58 $this->setBrowser('*firefox');
59 $this->setBrowserUrl(URL);
60 $this->setHost(SELENIUM_RC_HOST);
63 // protected function waitForPageToLoad($timeout)
65 // parent::waitForPageToLoad($timeout);
66 // $this->test->assertFalse($this->isTextPresent("Notice: Undefined variable:"));
67 // $this->test->assertFalse($this->isTextPresent("Notice: Undefined index:"));
68 // $this->test->assertFalse($this->isTextPresent("Warning: Missing argument"));
71 protected function init() {
72 $this->createProject('ProjectA');
75 $this->click("link=ProjectA");
76 $this->waitForPageToLoad("30000");
79 protected function login($username)
81 if ($username == 'admin') {
82 $password = 'myadmin';
84 $password = 'password';
87 $this->click("link=Log In");
88 $this->waitForPageToLoad("30000");
89 $this->type("form_loginname", $username);
90 $this->type("form_pw", $password);
91 $this->click("login");
92 $this->waitForPageToLoad("30000");
96 protected function logout()
98 // $this->click("link=Log Out");
99 $this->open( BASE ."/account/logout.php" );
100 $this->waitForPageToLoad("30000");
103 protected function switchUser($username)
106 $this->login($username);
109 protected function createProject ($name) {
110 $unix_name = strtolower($name);
112 // Create a simple project.
114 $this->click("link=Log In");
115 $this->waitForPageToLoad("30000");
116 $this->type("form_loginname", "admin");
117 $this->type("form_pw", "myadmin");
118 $this->click("login");
119 $this->waitForPageToLoad("30000");
120 $this->click("link=My Page");
121 $this->waitForPageToLoad("30000");
122 $this->click("link=Register Project");
123 $this->waitForPageToLoad("30000");
124 $this->type("full_name", $name);
125 $this->type("purpose", "This is a simple description for $name");
126 $this->type("description", "This is the public description for $name.");
127 $this->type("unix_name", $unix_name);
128 $this->click("//input[@name='scm' and @value='scmsvn']");
129 $this->click("submit");
130 $this->waitForPageToLoad("30000");
131 $this->assertTrue($this->isTextPresent("Your project has been submitted"));
132 $this->assertTrue($this->isTextPresent("you will receive notification of their decision and further instructions"));
133 $this->click("link=Site Admin");
134 $this->waitForPageToLoad("30000");
135 $this->click("link=Pending (P) (New Project Approval)");
136 $this->waitForPageToLoad("30000");
137 $this->click("document.forms['approve.$unix_name'].submit");
138 $this->waitForPageToLoad("30000");
139 $this->click("link=Home");
140 $this->waitForPageToLoad("30000");
141 $this->assertTrue($this->isTextPresent($name));
142 $this->click("link=$name");
143 $this->waitForPageToLoad("30000");
144 $this->assertTrue($this->isTextPresent("This is the public description for $name."));
145 $this->assertTrue($this->isTextPresent("This project has not yet categorized itself"));
148 protected function createUser ($login, $id)
151 $this->click("link=Admin");
152 $this->waitForPageToLoad("30000");
153 $this->click("link=Register a New User");
154 $this->waitForPageToLoad("30000");
155 $this->type("unix_name", $login);
156 $this->type("alt_user_name", $login);
157 $this->type("password1", "password");
158 $this->type("password2", "password");
159 $this->type("firstname", $login);
160 $this->type("lastname", "Lastname");
161 $this->type("email", $login."@debug.log");
162 $this->click("submit");
163 $this->waitForPageToLoad("30000");
164 $this->click("link=Site Admin");
165 $this->waitForPageToLoad("30000");
166 $this->click("link=Display Full User List/Edit Users");
167 $this->waitForPageToLoad("30000");
168 $this->click("//a[contains(@href, 'userlist.php?action=activate&user_id=$id')]");
169 $this->waitForPageToLoad("30000");
172 protected function activatePlugin($pluginName) {
174 $this->waitForPageToLoad("30000");
175 $this->login('admin');
176 $this->click("link=Site Admin");
177 $this->waitForPageToLoad("30000");
178 $this->click("link=Plugin Manager");
179 $this->waitForPageToLoad("30000");
180 $this->click($pluginName);
181 $this->click("//a[contains(@href, \"javascript:change('".ROOT."/admin/pluginman.php?update=$pluginName&action=activate','$pluginName');\")]");
182 $this->waitForPageToLoad("30000");