]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - maintenance/tests/selenium/suites/UserPreferencesTestCase.php
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / maintenance / tests / selenium / suites / UserPreferencesTestCase.php
1 <?php
2
3 /**
4  * Selenium server manager
5  *
6  * @file
7  * @ingroup Maintenance
8  * Copyright (C) 2010 Dan Nessett <dnessett@yahoo.com>
9  * http://citizendium.org/
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24  * http://www.gnu.org/copyleft/gpl.html
25  *
26  * @addtogroup Maintenance
27  *
28  */
29
30 class UserPreferencesTestCase extends SeleniumTestCase {
31
32     // Verify user information
33     public function testUserInfoDisplay() {
34
35         $this->open( $this->getUrl() .
36                 '/index.php?title=Main_Page&action=edit' );
37         $this->click( "link=My preferences" );
38         $this->waitForPageToLoad( "30000" );
39
40         // Verify correct username displayed in User Preferences
41         $this->assertEquals( $this->getText( "//li[@id='pt-userpage']/a" ),
42                 $this->getText( "//table[@id='mw-htmlform-info']/tbody/tr[1]/td[2]" ));
43
44         // Verify existing Signature Displayed correctly
45         $this->assertEquals( $this->selenium->getUser(),
46                 $this->getTable( "mw-htmlform-signature.0.1" ) );
47     }
48
49     // Verify change password
50     public function testChangePassword() {
51
52         $this->open( $this->getUrl() .
53                 '/index.php?title=Main_Page&action=edit' );
54         $this->click( "link=My preferences" );
55         $this->waitForPageToLoad( "30000" );
56
57         $this->click( "link=Change password" );
58         $this->waitForPageToLoad( "30000" );
59
60         $this->type( "wpPassword", "12345" );
61         $this->type( "wpNewPassword", "54321" );
62         $this->type( "wpRetype", "54321" );
63         $this->click( "//input[@value='Change password']" );
64         $this->waitForPageToLoad( "30000" );
65
66         $this->assertEquals( "Preferences", $this->getText( "firstHeading" ));
67
68         $this->click( "link=Change password" );
69         $this->waitForPageToLoad( "30000" );
70
71         $this->type( "wpPassword", "54321" );
72         $this->type( "wpNewPassword", "12345" );
73         $this->type( "wpRetype", "12345" );
74         $this->click( "//input[@value='Change password']" );
75         $this->waitForPageToLoad( "30000" );
76         $this->assertEquals( "Preferences", $this->getText( "firstHeading" ));
77
78         $this->click( "link=Change password" );
79         $this->waitForPageToLoad( "30000" );
80
81         $this->type( "wpPassword", "54321" );
82         $this->type( "wpNewPassword", "12345" );
83         $this->type( "wpRetype", "12345" );
84         $this->click( "//input[@value='Change password']" );
85         $this->waitForPageToLoad( "30000" );
86     }
87
88     // Verify successful preferences save
89     public function testSuccessfullSave() {
90
91         $this->open( $this->getUrl() .
92                 '/index.php?title=Main_Page&action=edit' );
93         $this->click( "link=My preferences" );
94         $this->waitForPageToLoad( "30000" );
95
96         $this->type( "mw-input-realname", "Test User" );
97         $this->click( "prefcontrol" );
98         $this->waitForPageToLoad( "30000" );
99
100         // Verify  "Your preferences have been saved." message
101         $this->assertEquals( "Your preferences have been saved.",
102                 $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ));
103         $this->type( "mw-input-realname", "" );
104         $this->click( "prefcontrol" );
105         $this->waitForPageToLoad( "30000" );
106
107     }
108
109     // Verify change signature
110     public function testChangeSignature() {
111
112         $this->open( $this->getUrl() .
113                 '/index.php?title=Main_Page&action=edit' );
114         $this->click( "link=My preferences" );
115         $this->waitForPageToLoad( "30000" );
116
117         $this->type( "mw-input-nickname", "TestSignature" );
118         $this->click( "prefcontrol" );
119         $this->waitForPageToLoad( "30000" );
120
121         // Verify change user signature
122         $this->assertEquals( "TestSignature", $this->getText( "link=TestSignature" ));
123         $this->type( "mw-input-nickname", "Test" );
124         $this->click( "prefcontrol" );
125         $this->waitForPageToLoad("30000");
126     }
127
128     // Verify change date format
129     public function testChangeDateFormatTimeZone() {
130
131         $this->open( $this->getUrl() .
132                 '/index.php?title=Main_Page&action=edit' );
133
134         $this->click( "link=My preferences" );
135         $this->waitForPageToLoad( "30000" );
136         $this->click( "link=Date and time" );
137         $this->waitForPageToLoad( "30000" );
138
139         $this->click( "mw-input-date-dmy" );
140         $this->select( "mw-input-timecorrection", "label=Asia/Colombo" );
141         $this->click( "prefcontrol" );
142         $this->waitForPageToLoad( "30000" );
143
144         // Verify Date format and time zome saved
145         $this->assertEquals( "Your preferences have been saved.",
146                 $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ));
147     }
148
149     // Verify restoring all default settings
150     public function testSetAllDefault() {
151
152         $this->open( $this->getUrl() .
153                 '/index.php?title=Main_Page&action=edit' );
154         $this->click( "link=My preferences" );
155         $this->waitForPageToLoad( "30000" );
156
157         // Verify restoring all default settings
158         $this->assertEquals( "Restore all default settings",
159                 $this->getText( "link=Restore all default settings" ));
160
161         $this->click("//*[@id='preferences']/div/a");
162         $this->waitForPageToLoad("30000");
163
164         // Verify 'This can not be undone' warning message displayed
165         $this->assertTrue($this->isElementPresent("//input[@value='Restore all default settings']"));
166
167         // Verify 'Restore all default settings' button available
168         $this->assertEquals("You can use this page to reset your preferences to the site defaults. This cannot be undone.",
169                 $this->getText("//div[@id='bodyContent']/p"));
170
171         $this->click("//input[@value='Restore all default settings']");
172         $this->waitForPageToLoad("30000");
173
174         // Verify preferences saved successfully
175         $this->assertEquals("Your preferences have been saved.",
176                 $this->getText("//div[@id='bodyContent']/div[4]/strong/p"));
177     }
178 }
179