phpcs: More require/include is not a function
[lhc/web/wiklou.git] / tests / selenium / installer / MediaWikiInstallationCommonFunction.php
1 <?php
2 /**
3 * MediaWikiInstallationCommonFunction
4 *
5 * @file
6 * @ingroup Maintenance
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * http://www.gnu.org/copyleft/gpl.html
24 */
25
26 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
27 require_once __DIR__ . '/MediaWikiInstallationConfig.php';
28 require_once __DIR__ . '/MediaWikiInstallationMessage.php';
29 require_once __DIR__ . '/MediaWikiInstallationVariables.php';
30
31 class MediaWikiInstallationCommonFunction extends PHPUnit_Extensions_SeleniumTestCase {
32 function setUp() {
33 $this->setBrowser( TEST_BROWSER );
34 $this->setBrowserUrl( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/" );
35 }
36
37 public function navigateInitialpage() {
38 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/" );
39 }
40
41 // Navigate to the 'Language' page
42 public function navigateLanguagePage() {
43 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
44 }
45
46 // Navigate to the 'Welcome to MediaWiki' page
47 public function navigateWelcometoMediaWikiPage() {
48 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
49 $this->click( "submit-continue " );
50 $this->waitForPageToLoad( PAGE_LOAD_TIME );
51 }
52
53 // Navigate yo 'Connect to Database' page
54 public function navigateConnetToDatabasePage() {
55 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
56
57 // 'Welcome to MediaWiki!' page
58 $this->click( "submit-continue" );
59 $this->waitForPageToLoad( PAGE_LOAD_TIME );
60
61 // 'Connect to Database' page
62 $this->click( "submit-continue" );
63 $this->waitForPageToLoad( PAGE_LOAD_TIME );
64 }
65
66 // Navigate to the 'Database Settings' page
67 public function navigateDatabaseSettingsPage( $databaseName ) {
68 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
69
70 // 'Welcome to MediaWiki!' page
71 $this->click( "submit-continue" );
72 $this->waitForPageToLoad( PAGE_LOAD_TIME );
73
74 // 'Connect to Database' page
75 $this->click( "submit-continue" );
76 $this->waitForPageToLoad( PAGE_LOAD_TIME );
77
78 $this->type( "mysql_wgDBname", $databaseName );
79 $this->click( "submit-continue" );
80 $this->waitForPageToLoad( PAGE_LOAD_TIME );
81 }
82
83 // Navigate to the 'Name' page
84 public function navigateNamePage( $databaseName ) {
85 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
86
87 // 'Welcome to MediaWiki!' page
88 $this->click( "submit-continue" );
89 $this->waitForPageToLoad( PAGE_LOAD_TIME );
90
91 // 'Connect to Database' page
92 $this->click( "submit-continue" );
93 $this->waitForPageToLoad( PAGE_LOAD_TIME );
94
95 $this->type( "mysql_wgDBname", $databaseName );
96 $this->click( "submit-continue" );
97 $this->waitForPageToLoad( PAGE_LOAD_TIME );
98
99 // Database settings
100 $this->click( "submit-continue" );
101 $this->waitForPageToLoad( PAGE_LOAD_TIME );
102 }
103
104 // Navigate 'Options' page
105 public function navigateOptionsPage( $databaseName ) {
106 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
107
108 // 'Welcome to MediaWiki!' page
109 $this->click( "submit-continue" );
110 $this->waitForPageToLoad( PAGE_LOAD_TIME );
111
112 // 'Connect to Database' page
113 $this->click( "submit-continue" );
114 $this->waitForPageToLoad( PAGE_LOAD_TIME );
115
116 $this->type( "mysql_wgDBname", $databaseName );
117 $this->click( "submit-continue" );
118 $this->waitForPageToLoad( PAGE_LOAD_TIME );
119
120 // Database settings
121 $this->click( "submit-continue" );
122 $this->waitForPageToLoad( PAGE_LOAD_TIME );
123
124 // Name
125 $this->type( "config_wgSitename", NAME_OF_WIKI );
126 $this->type( "config__AdminName", ADMIN_USER_NAME );
127 $this->type( "config__AdminPassword", ADMIN_PASSWORD );
128 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD );
129 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS );
130
131 $this->click( "submit-continue" );
132 $this->waitForPageToLoad( PAGE_LOAD_TIME );
133 }
134
135 // Navigate 'Install' page
136 public function navigateInstallPage( $databaseName ) {
137 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
138
139 // 'Welcome to MediaWiki!' page
140 $this->click( "submit-continue" );
141 $this->waitForPageToLoad( PAGE_LOAD_TIME );
142
143 // 'Connect to Database' page
144 $this->click( "submit-continue" );
145 $this->waitForPageToLoad( PAGE_LOAD_TIME );
146
147 $this->type( "mysql_wgDBname", $databaseName );
148 $this->click( "submit-continue" );
149 $this->waitForPageToLoad( PAGE_LOAD_TIME );
150
151 // Database settings
152 $this->click( "submit-continue" );
153 $this->waitForPageToLoad( PAGE_LOAD_TIME );
154
155 // Name
156 $this->type( "config_wgSitename", NAME_OF_WIKI );
157 $this->type( "config__AdminName", ADMIN_USER_NAME );
158 $this->type( "config__AdminPassword", ADMIN_PASSWORD );
159 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD );
160 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS );
161
162 $this->click( "submit-continue" );
163 $this->waitForPageToLoad( PAGE_LOAD_TIME );
164
165 // Options page
166 $this->click( "submit-continue" );
167 $this->waitForPageToLoad( PAGE_LOAD_TIME );
168 }
169
170 // Navigate to 'Complete' page
171 public function navigateCompletePage( $databaseName ) {
172 $this->open( "http://" . HOST_NAME . ":" . PORT . "/" . DIRECTORY_NAME . "/config/index.php" );
173
174 // 'Welcome to MediaWiki!' page
175 $this->click( "submit-continue" );
176 $this->waitForPageToLoad( PAGE_LOAD_TIME );
177
178 // 'Connect to Database' page
179 $this->click( "submit-continue" );
180 $this->waitForPageToLoad( PAGE_LOAD_TIME );
181
182 $this->type( "mysql_wgDBname", $databaseName );
183 $this->click( "submit-continue" );
184 $this->waitForPageToLoad( PAGE_LOAD_TIME );
185
186 // Database settings
187 $this->click( "submit-continue" );
188 $this->waitForPageToLoad( PAGE_LOAD_TIME );
189
190 // Name
191 $this->type( "config_wgSitename", NAME_OF_WIKI );
192 $this->type( "config__AdminName", ADMIN_USER_NAME );
193 $this->type( "config__AdminPassword", ADMIN_PASSWORD );
194 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD );
195 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS );
196
197 $this->click( "submit-continue" );
198 $this->waitForPageToLoad( PAGE_LOAD_TIME );
199
200 // Options page
201 $this->click( "submit-continue" );
202 $this->waitForPageToLoad( PAGE_LOAD_TIME );
203
204 // Install page
205 $this->click( "submit-continue" );
206 $this->waitForPageToLoad( PAGE_LOAD_TIME );
207 $this->chooseCancelOnNextConfirmation();
208 }
209
210 // Complete the Name page fields
211 public function completeNamePage() {
212 $this->type( "config_wgSitename", NAME_OF_WIKI );
213 $this->type( "config__AdminName", ADMIN_USER_NAME );
214 $this->type( "config__AdminPassword", ADMIN_PASSWORD );
215 $this->type( "config__AdminPassword2", ADMIN_RETYPE_PASSWORD );
216 $this->type( "config__AdminEmail", ADMIN_EMAIL_ADDRESS );
217 $this->click( "submit-continue" );
218 $this->waitForPageToLoad( PAGE_LOAD_TIME );
219 }
220
221 // Clicking on the 'Continue' button in any MediaWiki page
222 public function clickContinueButton() {
223 $this->click( "submit-continue" );
224 $this->waitForPageToLoad( PAGE_LOAD_TIME );
225 }
226
227 // Clicking on the 'Back' button in any MediaWiki page
228 public function clickBackButton() {
229 $this->click( "submit-back" );
230 $this->waitForPageToLoad( PAGE_LOAD_TIME );
231 }
232
233 // Restarting the installation
234 public function restartInstallation() {
235 $this->click( "link=Restart installation" );
236 $this->waitForPageToLoad( PAGE_LOAD_TIME );
237 $this->click( "submit-restart" );
238 $this->waitForPageToLoad( PAGE_LOAD_TIME );
239 }
240
241 // Verify 'MediaWiki' logo available in the initial screen
242 public function mediaWikiLogoPresentInitialScreen() {
243 $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ) );
244 }
245
246 // Verify 'MediaWiki' logo available
247 public function mediaWikiLogoPresent() {
248 $this->assertTrue( $this->isElementPresent( "//div[@id='p-logo']/a" ) );
249 }
250
251 public function completePageSuccessfull() {
252 $this->assertEquals( "Complete!",
253 $this->getText( "//div[@id='bodyContent']/div/div/h2" ) );
254
255 // 'Congratulations!' text should be available in the 'Complete!' page.
256 $this->assertEquals( "Congratulations!",
257 $this->getText( "//div[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]/p[1]/b" ) );
258 }
259 }