API: trunk/phase3 is now mediawiki/core
[lhc/web/wiklou.git] / tests / selenium / suites / UserPreferencesTestCase.php
1 <?php
2
3 /**
4 * Selenium server manager
5 *
6 * @file
7 * @ingroup Testing
8 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
9 * http://www.calcey.com/
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 Testing
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( SeleniumTestConstants::LINK_START."My preferences" );
38 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::LINK_START."My preferences" );
55 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
56
57 $this->click( SeleniumTestConstants::LINK_START."Change password" );
58 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
65
66 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ));
67
68 $this->click( SeleniumTestConstants::LINK_START."Change password" );
69 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
76 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ));
77
78 $this->click( SeleniumTestConstants::LINK_START."Change password" );
79 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::LINK_START."My preferences" );
94 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
95
96 $this->type( "mw-input-realname", "Test User" );
97 $this->click( "prefcontrol" );
98 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::LINK_START."My preferences" );
115 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
116
117 $this->type( "mw-input-nickname", "TestSignature" );
118 $this->click( "prefcontrol" );
119 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
120
121 // Verify change user signature
122 $this->assertEquals( "TestSignature", $this->getText( SeleniumTestConstants::LINK_START."TestSignature" ));
123 $this->type( "mw-input-nickname", "Test" );
124 $this->click( "prefcontrol" );
125 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::LINK_START."My preferences" );
135 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
136 $this->click( SeleniumTestConstants::LINK_START."Date and time" );
137 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
138
139 $this->click( "mw-input-date-dmy" );
140 $this->select( "mw-input-timecorrection", "label=Asia/Colombo" );
141 $this->click( "prefcontrol" );
142 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::LINK_START."My preferences" );
155 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
156
157 // Verify restoring all default settings
158 $this->assertEquals( "Restore all default settings",
159 $this->getText( SeleniumTestConstants::LINK_START."Restore all default settings" ));
160
161 $this->click("//*[@id='preferences']/div/a");
162 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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