tests: mock parser tests file access
[mediawiki.git] / tests / selenium / suites / UserPreferencesTestCase.php
blobc70e38fb6e4fc448a48e4fa14b6906a918cc7de1
1 <?php
2 /**
3 * Selenium server manager
5 * @file
6 * @ingroup Testing
7 * Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
8 * http://www.calcey.com/
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.
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.
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
26 class UserPreferencesTestCase extends SeleniumTestCase {
27 // Verify user information
28 public function testUserInfoDisplay() {
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 );
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]" ) );
39 // Verify existing Signature Displayed correctly
40 $this->assertEquals( $this->selenium->getUser(),
41 $this->getTable( "mw-htmlform-signature.0.1" ) );
44 // Verify change password
45 public function testChangePassword() {
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 );
52 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
53 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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 );
61 $this->assertEquals( "Preferences", $this->getText( "firstHeading" ) );
63 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
64 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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" ) );
73 $this->click( SeleniumTestConstants::LINK_START . "Change password" );
74 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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 );
83 // Verify successful preferences save
84 public function testSuccessfullSave() {
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 );
91 $this->type( "mw-input-realname", "Test User" );
92 $this->click( "prefcontrol" );
93 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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 );
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 );
110 $this->type( "mw-input-nickname", "TestSignature" );
111 $this->click( "prefcontrol" );
112 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
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 );
121 // Verify change date format
122 public function testChangeDateFormatTimeZone() {
123 $this->open( $this->getUrl() .
124 '/index.php?title=Main_Page&action=edit' );
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 );
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 );
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" ) );
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 );
148 // Verify restoring all default settings
149 $this->assertEquals( "Restore all default settings",
150 $this->getText( SeleniumTestConstants::LINK_START . "Restore all default settings" ) );
152 $this->click( "//*[@id='preferences']/div/a" );
153 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
155 // Verify 'This can not be undone' warning message displayed
156 $this->assertTrue( $this->isElementPresent( "//input[@value='Restore all default settings']" ) );
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" ) );
162 $this->click( "//input[@value='Restore all default settings']" );
163 $this->waitForPageToLoad( SeleniumTestConstants::WIKI_TEST_WAIT_TIME );
165 // Verify preferences saved successfully
166 $this->assertEquals( "Your preferences have been saved.",
167 $this->getText( "//div[@id='bodyContent']/div[4]/strong/p" ) );