Do not output numberofviews, if $wgDisableCounters = true
[lhc/web/wiklou.git] / tests / selenium / suites / UserPreferencesTestCase.php
1 <?php
2 /**
3 * Selenium server manager
4 *
5 * @file
6 * @ingroup Testing
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 class UserPreferencesTestCase extends SeleniumTestCase {
27 // Verify user information
28 public function testUserInfoDisplay() {
29
30 $this->open( $this->getUrl() .
31 '/index.php?title=Main_Page&action=edit' );
32 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
33 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
34
35 // Verify correct username displayed in User Preferences
36 $this->assertEquals( $this->getText( "//li[@id='pt-userpage']/a" ),
37 $this->getText( "//table[@id='mw-htmlform-info']/tbody/tr[1]/td[2]" ) );
38
39 // Verify existing Signature Displayed correctly
40 $this->assertEquals( $this->selenium->getUser(),
41 $this->getTable( "mw-htmlform-signature.0.1" ) );
42 }
43
44 // Verify change password
45 public function testChangePassword() {
46
47 $this->open( $this->getUrl() .
48 '/index.php?title=Main_Page&action=edit' );
49 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
50 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
51
52 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
53 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
54
55 $this->type( "wpPassword", "12345" );
56 $this->type( "wpNewPassword", "54321" );
57 $this->type( "wpRetype", "54321" );
58 $this->click( "//input[@value='Change password']" );
59 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
60
61 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) );
62
63 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
64 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
65
66 $this->type( "wpPassword", "54321" );
67 $this->type( "wpNewPassword", "12345" );
68 $this->type( "wpRetype", "12345" );
69 $this->click( "//input[@value='Change password']" );
70 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
71 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) );
72
73 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
74 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
75
76 $this->type( "wpPassword", "54321" );
77 $this->type( "wpNewPassword", "12345" );
78 $this->type( "wpRetype", "12345" );
79 $this->click( "//input[@value='Change password']" );
80 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
81 }
82
83 // Verify successful preferences save
84 public function testSuccessfullSave() {
85
86 $this->open( $this->getUrl() .
87 '/index.php?title=Main_Page&action=edit' );
88 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
89 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
90
91 $this->type( "mw-input-realname", "Test User" );
92 $this->click( "prefcontrol" );
93 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
94
95 // Verify "Your preferences have been saved." message
96 $this->assertEquals( "Your preferences have been saved.",
97 $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );
98 $this->type( "mw-input-realname", "" );
99 $this->click( "prefcontrol" );
100 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
101 }
102
103 // Verify change signature
104 public function testChangeSignature() {
105 $this->open( $this->getUrl() .
106 '/index.php?title=Main_Page&action=edit' );
107 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
108 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
109
110 $this->type( "mw-input-nickname", "TestSignature" );
111 $this->click( "prefcontrol" );
112 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
113
114 // Verify change user signature
115 $this->assertEquals( "TestSignature", $this->getText( SeleniumTestConstants::LINK_START . "TestSignature" ) );
116 $this->type( "mw-input-nickname", "Test" );
117 $this->click( "prefcontrol" );
118 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
119 }
120
121 // Verify change date format
122 public function testChangeDateFormatTimeZone() {
123 $this->open( $this->getUrl() .
124 '/index.php?title=Main_Page&action=edit' );
125
126 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
127 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
128 $this->click( SeleniumTestConstants::LINK_START . "Date and time" );
129 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
130
131 $this->click( "mw-input-date-dmy" );
132 $this->select( "mw-input-timecorrection", "label=Asia/Colombo" );
133 $this->click( "prefcontrol" );
134 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
135
136 // Verify Date format and time zome saved
137 $this->assertEquals( "Your preferences have been saved.",
138 $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );
139 }
140
141 // Verify restoring all default settings
142 public function testSetAllDefault() {
143 $this->open( $this->getUrl() .
144 '/index.php?title=Main_Page&action=edit' );
145 $this->click( SeleniumTestConstants::LINK_START . "My preferences" );
146 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
147
148 // Verify restoring all default settings
149 $this->assertEquals( "Restore all default settings",
150 $this->getText( SeleniumTestConstants::LINK_START . "Restore all default settings" ) );
151
152 $this->click( "//*[@id='preferences']/div/a" );
153 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
154
155 // Verify 'This can not be undone' warning message displayed
156 $this->assertTrue( $this->isElementPresent( "//input[@value='Restore all default settings']" ) );
157
158 // Verify 'Restore all default settings' button available
159 $this->assertEquals( "You can use this page to reset your preferences to the site defaults. This cannot be undone.",
160 $this->getText( "//div[@id='bodyContent']/p" ) );
161
162 $this->click( "//input[@value='Restore all default settings']" );
163 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
164
165 // Verify preferences saved successfully
166 $this->assertEquals( "Your preferences have been saved.",
167 $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );
168 }
169 }
170