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