PageRenderTime 1120ms CodeModel.GetById 43ms RepoModel.GetById 5ms app.codeStats 0ms

/tests/selenium/installer/MediaWikiUserInterfaceTestCase.php

https://bitbucket.org/brunodefraine/mediawiki
PHP | 531 lines | 287 code | 124 blank | 120 comment | 7 complexity | de254b3258d528bcfdefb11770fb4fcd MD5 | raw file
Possible License(s): GPL-2.0, Apache-2.0, LGPL-3.0
  1. <?php
  2. /**
  3. * MediaWikiUserInterfaceTestCase
  4. *
  5. * @file
  6. * @ingroup Maintenance
  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. * @addtogroup Maintenance
  26. *
  27. */
  28. require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
  29. /**
  30. * Test Case ID : 18 - 27 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
  31. * Test Case Name : UI of MediaWiki initial/ Language/ Welcome to MediaWiki!/ Connect to database/
  32. * Database settings/ Name/ Options/ Install/ Complete/ Restart Inslation pages
  33. * Version : MediaWiki 1.18alpha
  34. */
  35. class MediaWikiUserInterfaceTestCase extends MediaWikiInstallationCommonFunction {
  36. function setUp() {
  37. parent::setUp();
  38. }
  39. public function testInitialPageUI() {
  40. parent::navigateInitialpage();
  41. // MediaWiki logo available
  42. $this->assertTrue( $this->isElementPresent( "//img[@alt='The MediaWiki logo']" ));
  43. // 'MediaWiki 1.18alpha' text available
  44. $this->assertEquals( "MediaWiki 1.18alpha", $this->getText( "//h1" ));
  45. // 'LocalSettings.php not found.' text available
  46. $this->assertEquals( "LocalSettings.php not found.", $this->getText( "//p[1]" ));
  47. // 'Please set up the wiki first' text available
  48. $this->assertEquals( "Please set up the wiki first.", $this->getText( "//p[2]" ));
  49. // 'set up the wiki' link available
  50. $this->assertTrue($this->isElementPresent( "link=set up the wiki" ));
  51. }
  52. public function testlanguagePageUI() {
  53. parent::navigateLanguagePage();
  54. // Verify 'Language' heading
  55. $this->assertEquals( "Language", $this->getText( LINK_DIV."h2" ));
  56. // 'Your language' label available
  57. $this->assertEquals( "Your language:",
  58. $this->getText( LINK_FORM."div[1]/div[1]/label" ));
  59. // 'Your language' dropdown available
  60. $this->assertTrue( $this->isElementPresent( "UserLang" ));
  61. // 'Wiki language' label available
  62. $this->assertEquals( "Wiki language:",
  63. $this->getText( LINK_FORM."div[2]/div[1]/label" ));
  64. // 'Wiki language' dropdown available
  65. $this->assertTrue($this->isElementPresent( "ContLang" ));
  66. }
  67. public function testWelcometoMediaWikiUI() {
  68. parent::navigateWelcometoMediaWikiPage();
  69. // Verify 'Welcome to MediaWiki!' heading
  70. $this->assertEquals( "Welcome to MediaWiki!",
  71. $this->getText( LINK_DIV."h2" ));
  72. // Verify environment ok text displayed.
  73. $this->assertEquals( "The environment has been checked.You can install MediaWiki.",
  74. $this->getText( LINK_DIV."div[6]/span" ));
  75. }
  76. public function testConnectToDatabaseUI() {
  77. parent::navigateConnetToDatabasePage();
  78. // 'MYSQL radio button available
  79. $this->assertEquals( "MySQL",
  80. $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" ));
  81. $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[1]" ));
  82. // 'SQLite' radio button available
  83. $this->assertTrue( $this->isElementPresent( LINK_FORM."div[2]/div[2]/ul/li[2]" ));
  84. $this->assertEquals( "SQLite", $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label "));
  85. // 'Database host' label available
  86. $this->assertEquals( "Database host:", $this->getText( "//div[@id='DB_wrapper_mysql']/div/div[1]/label" ));
  87. // 'Database host' text box default to 'localhost'
  88. $this->assertEquals( "localhost", $this->getValue( "mysql_wgDBserver" ));
  89. // 'Identify this wiki' section available
  90. $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ));
  91. // 'Identify this wiki' label available
  92. $this->assertEquals( "Identify this wiki", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/legend" ));
  93. // 'Database name' lable available
  94. $this->assertEquals( "Database name:",
  95. $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[1]/div[1]/label" ));
  96. // Verify 'Database name:' text box is default to 'my_wiki'
  97. $this->assertEquals( "my_wiki", $this->getValue( "mysql_wgDBname" ));
  98. // Verify 'Database table prefix:' label available
  99. $this->assertEquals( "Database table prefix:",
  100. $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[1]/div[2]/div[1]/label" ));
  101. // 'User account for installation' section available
  102. $this->assertTrue( $this->isElementPresent( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ));
  103. // 'User account for installation' label available
  104. $this->assertEquals( "User account for installation", $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/legend" ));
  105. // 'Database username' label available
  106. $this->assertEquals( "Database username:",
  107. $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[1]/div[1]/label" ));
  108. // 'Database username' text box defaults to 'root'
  109. $this->assertEquals("root", $this->getValue( "mysql__InstallUser" ));
  110. // 'Database password' label available
  111. $this->assertEquals( "Database password:",
  112. $this->getText( "//div[@id='DB_wrapper_mysql']/fieldset[2]/div[2]/div[1]/label" ));
  113. }
  114. public function testDatabaseSettingsUI() {
  115. $databaseName = DB_NAME_PREFIX."_db_settings_UI";
  116. parent::navigateDatabaseSettingsPage( $databaseName );
  117. // 'Database settings' text available.
  118. $this->assertEquals( "Database settings", $this->getText( LINK_DIV."h2" ));
  119. // 'Database account for web access' section available
  120. $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" ));
  121. // 'Database account for web access' label available
  122. $this->assertEquals( "Database account for web access", $this->getText( LINK_FORM."fieldset/legend" ));
  123. // 'Use the same account as for installation' check box available
  124. $this->assertEquals( "Use the same account as for installation", $this->getText( LINK_FORM."fieldset/div[1]/label" ));
  125. // 'Use the same account as for installation' check box is selected by default
  126. $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ));
  127. // 'Use the same account as for installation' check box deselected
  128. $this->click( "mysql__SameAccount" );
  129. // verify 'Use the same account as for installation' check box is not selected
  130. $this->assertEquals( "off", $this->getValue( "mysql__SameAccount" ));
  131. // 'Database username' label available
  132. $this->assertEquals( "Database username:", $this->getText( "//div[@id='dbOtherAccount']/div[1]/div[1]/label" ));
  133. // 'Database username' text box is default to the 'wikiuser'
  134. $this->assertEquals( "wikiuser", $this->getValue( "mysql_wgDBuser" ));
  135. // 'Database password' label available
  136. $this->assertEquals( "Database password:", $this->getText( "//div[@id='dbOtherAccount']/div[2]/div[1]/label" ));
  137. // 'Create the account if it does not already exist' label available
  138. $this->assertEquals( "Create the account if it does not already exist", $this->getText( "//div[@id='dbOtherAccount']/div[4]/label" ));
  139. // 'Create the account if it does not already exist' check box is not selected by default
  140. $this->assertEquals( "off" , $this->getValue( "mysql__CreateDBAccount" ));
  141. // 'Create the account if it does not already exist' check box selected
  142. $this->click( "mysql__CreateDBAccount" );
  143. // Verify 'Create the account if it does not already exist' check box is selected
  144. $this->assertEquals( "on" , $this->getValue( "mysql__CreateDBAccount" ));
  145. $this->click( "mysql__SameAccount" );
  146. $this->assertEquals( "on", $this->getValue( "mysql__SameAccount" ));
  147. // 'Storage engine' label available
  148. $this->assertEquals( "Storage engine:",
  149. $this->getText( LINK_FORM."div[1]/div[1]/label"));
  150. // 'InnoDB' label available
  151. $this->assertEquals( "InnoDB",
  152. $this->getText( LINK_FORM."div[1]/div[2]/ul/li[1]/label" ));
  153. // 'InnoDB' radio button available
  154. $this->assertTrue( $this->isElementPresent( "mysql__MysqlEngine_InnoDB" ));
  155. // 'MyISAM' label available
  156. $this->assertEquals( "MyISAM", $this->getText( LINK_FORM."div[1]/div[2]/ul/li[2]/label" ));
  157. // 'MyISAM' radio button available
  158. $this->assertTrue($this->isElementPresent( "mysql__MysqlEngine_MyISAM" ));
  159. // 'Database character set' label available
  160. $this->assertEquals( "Database character set:",
  161. $this->getText( LINK_FORM."div[3]/div[1]/label" ));
  162. // 'Binary' radio button available
  163. $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_binary" ));
  164. // 'Binary' radio button available
  165. $this->assertEquals( "Binary", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[1]/label" ));
  166. // 'UTF-8' radio button available
  167. $this->assertTrue( $this->isElementPresent( "mysql__MysqlCharset_utf8" ));
  168. // 'UTF-8' label available
  169. $this->assertEquals( "UTF-8", $this->getText( LINK_FORM."div[3]/div[2]/ul/li[2]/label" ));
  170. // 'Binary' radio button is selected
  171. $this->assertEquals( "on", $this->getValue( "mysql__MysqlCharset_binary" ));
  172. }
  173. public function testNamePageUI() {
  174. $databaseName = DB_NAME_PREFIX."_name_UI";
  175. parent::navigateNamePage($databaseName);
  176. // 'Name of wiki' text box available
  177. $this->assertEquals( "Name of wiki:",
  178. $this->getText( LINK_FORM."div[1]/div[1]/label" ));
  179. $this->assertTrue( $this->isElementPresent( "config_wgSitename" ));
  180. // 'Project namespace' label available
  181. $this->assertEquals( "Project namespace:",
  182. $this->getText( LINK_FORM."div[2]/div[1]/label" ));
  183. // 'Same as the wiki name' radio button available
  184. $this->assertTrue( $this->isElementPresent( "config__NamespaceType_site-name" ));
  185. // 'Project' radio button available
  186. $this->assertTrue( $this->isElementPresent( "config__NamespaceType_generic" ));
  187. // 'Project' radio button available
  188. $this->assertTrue( $this->isElementPresent( "config__NamespaceType_other" ));
  189. // 'Same as the wiki name' label available
  190. $this->assertEquals( "Same as the wiki name:",
  191. $this->getText( LINK_FORM."div[2]/div[2]/ul/li[1]/label" ));
  192. // 'Project' label available
  193. $this->assertEquals("Project",
  194. $this->getText( LINK_FORM."div[2]/div[2]/ul/li[2]/label" ));
  195. // 'Project' label available
  196. $this->assertEquals( "Other (specify)",
  197. $this->getText( LINK_FORM."div[2]/div[2]/ul/li[3]/label" ));
  198. // 'Same as the wiki name' radio button selected by default
  199. $this->assertEquals( "on", $this->getValue( "config__NamespaceType_site-name" ));
  200. // 'Administrator account' section available
  201. $this->assertTrue( $this->isElementPresent( LINK_FORM."fieldset" ));
  202. // 'Administrator account' label available
  203. $this->assertEquals( "Administrator account",
  204. $this->getText( LINK_FORM."fieldset/legend" ));
  205. // 'Your Name' label available
  206. $this->assertEquals( "Your name:",
  207. $this->getText( LINK_FORM."fieldset/div[1]/div[1]/label" ));
  208. // 'Your Name' text box available
  209. $this->assertTrue( $this->isElementPresent( "config__AdminName" ));
  210. // 'Password' label available
  211. $this->assertEquals( "Password:",
  212. $this->getText( LINK_FORM."fieldset/div[2]/div[1]/label" ));
  213. // 'Password' text box available
  214. $this->assertTrue( $this->isElementPresent( "config__AdminPassword" ));
  215. // 'Password again' label available
  216. $this->assertEquals( "Password again:",
  217. $this->getText( LINK_FORM."fieldset/div[3]/div[1]/label" ));
  218. // 'Password again' text box available
  219. $this->assertTrue( $this->isElementPresent( "config__AdminPassword2" ));
  220. // 'Email address' label avaialble
  221. $this->assertEquals( "E-mail address:",
  222. $this->getText( LINK_FORM."fieldset/div[4]/div[1]/label" ));
  223. // 'Email address' text box available
  224. $this->assertTrue( $this->isElementPresent( "config__AdminEmail" ));
  225. // Message displayed
  226. $this->assertEquals( "You are almost done! You can now skip the remaining configuration and install the wiki right now.",
  227. $this->getText( LINK_FORM."/div[4]/div[2]/p" ));
  228. // 'Ask me more questions.' radio button available
  229. $this->assertTrue( $this->isElementPresent( "config__SkipOptional_continue" ));
  230. // 'Ask me more questions.' label available
  231. $this->assertEquals( "Ask me more questions.",
  232. $this->getText( LINK_FORM."div[5]/div[2]/ul/li[1]/label" ));
  233. // 'I'm bored already, just install the wiki' radio button is avaiable
  234. $this->assertTrue( $this->isElementPresent( "config__SkipOptional_skip" ));
  235. // 'I'm bored already, just install the wiki' label available
  236. $this->assertEquals( "I'm bored already, just install the wiki.",
  237. $this->getText( LINK_FORM."div[5]/div[2]/ul/li[2]/label" ));
  238. // 'Ask me more questions.' radio button is default selected
  239. $this->assertEquals( "on", $this->getValue( "config__SkipOptional_continue" ));
  240. }
  241. public function testOptionPageUI() {
  242. $databaseName = DB_NAME_PREFIX."_options_UI";
  243. parent::navigateOptionsPage($databaseName);
  244. // 'Options' label available
  245. $this->assertEquals( "Options", $this->getText( LINK_DIV."h2"));
  246. // 'Return e-mail address' label available
  247. $this->assertEquals( "Return e-mail address:", $this->getText( "//div[@id='emailwrapper']/div[1]/div[1]/label" ));
  248. // 'Return e-mail address' text box available
  249. $this->assertTrue( $this->isElementPresent( "config_wgPasswordSender" ));
  250. // Text 'apache@localhost' is default value of the 'Return e-mail address' text box
  251. $this->assertEquals( "apache@localhost", $this->getValue( "config_wgPasswordSender" ));
  252. // 'Logo URL' label available
  253. $this->assertEquals( "Logo URL:", $this->getText( LINK_FORM."fieldset[2]/div[3]/div[1]/label" ));
  254. // 'Logo URL' text box available
  255. $this->assertTrue( $this->isElementPresent( "config_wgLogo" ));
  256. // Correct path available in the 'Logo URL' text box
  257. $this->assertEquals( "/wiki/skins/common/images/wiki.png", $this->getValue( "config_wgLogo" ));
  258. // 'Enable file uploads' radio button available
  259. $this->assertTrue( $this->isElementPresent( "config_wgEnableUploads" ));
  260. // 'Enable file uploads' label available
  261. $this->assertEquals( "Enable file uploads",
  262. $this->getText( LINK_FORM."fieldset[2]/div[1]/label" ));
  263. // 'Enable file uploads' check box is not selected
  264. $this->assertEquals( "off", $this->getValue( "config_wgEnableUploads" ));
  265. $this->click( "config_wgEnableUploads" );
  266. // 'Directory for deleted files' label available
  267. $this->assertEquals( "Directory for deleted files:",
  268. $this->getText( "//div[@id='uploadwrapper']/div/div[1]/label" ));
  269. // 'Directory for deleted files' text box available
  270. $this->assertTrue( $this->isElementPresent( "config_wgDeletedDirectory" ));
  271. // Correct path available in the 'Directory for deleted files' text box
  272. $this->assertEquals( "C:\\wamp\\www\\".DIRECTORY_NAME."/images/deleted",
  273. $this->getValue( "config_wgDeletedDirectory" ));
  274. }
  275. public function testInstallPageUI() {
  276. $databaseName = DB_NAME_PREFIX."_install_UI";
  277. parent::navigateInstallPage( $databaseName );
  278. // Verify installation done messages display
  279. $this->assertEquals( "Setting up database... done",
  280. $this->getText( LINK_FORM."ul/li[1]" ));
  281. $this->assertEquals( "Creating tables... done",
  282. $this->getText( LINK_FORM."ul/li[2]" ));
  283. $this->assertEquals( "Creating database user... done",
  284. $this->getText( LINK_FORM."ul/li[3]" ));
  285. $this->assertEquals( "Populating default interwiki table... done",
  286. $this->getText( LINK_FORM."ul/li[4]" ));
  287. $this->assertEquals( "Generating secret key... done",
  288. $this->getText( LINK_FORM."ul/li[5]" ));
  289. $this->assertEquals( "Generating default upgrade key... done",
  290. $this->getText( LINK_FORM."ul/li[6]" ));
  291. $this->assertEquals( "Creating administrator user account... done",
  292. $this->getText( LINK_FORM."ul/li[7]" ));
  293. $this->assertEquals( "Creating main page with default content... done",
  294. $this->getText( LINK_FORM."ul/li[8]" ));
  295. }
  296. public function testCompletePageUI() {
  297. $databaseName = DB_NAME_PREFIX."_complete_UI";
  298. parent::navigateCompletePage( $databaseName );
  299. // 'Congratulations!' text display
  300. $this->assertEquals("Congratulations!",
  301. $this->getText( LINK_FORM."div[1]/div[2]/p[1]/b"));
  302. // 'LocalSettings.php' generated message display
  303. $this->assertEquals( "The installer has generated a LocalSettings.php file. It contains all your configuration.",
  304. $this->getText( LINK_FORM."div[1]/div[2]/p[2]" ));
  305. // 'Download LocalSettings.php'' link available
  306. $this->assertTrue( $this->isElementPresent( "link=Download LocalSettings.php" ));
  307. // 'enter your wiki' link available
  308. $this->assertTrue($this->isElementPresent("link=Folder/index.php enter your wiki"));
  309. }
  310. public function testRestartInstallation() {
  311. parent::navigateConnetToDatabasePage();
  312. $this->click( "link=Restart installation" );
  313. $this->waitForPageToLoad( PAGE_LOAD_TIME );
  314. // Restart installation' label should be available.
  315. $this->assertEquals( "Restart installation", $this->getText( LINK_DIV."h2" ));
  316. //'Do you want to clear all saved data that you have entered and restart the installation process?' label available
  317. $this->assertEquals( "Do you want to clear all saved data that you have entered and restart the installation process?",
  318. $this->getText( "//*[@id='bodyContent']/div/div/div[2]/form/div[1]/div[2]" ));
  319. // 'Back' button available
  320. $this->assertTrue($this->isElementPresent( "submit-back" ));
  321. // 'Restart' button available
  322. $this->assertTrue($this->isElementPresent( "submit-restart" ));
  323. }
  324. public function testMediaWikiLogoAvailability() {
  325. $databaseName = DB_NAME_PREFIX."_mediawiki_logo";
  326. parent::navigateInitialpage();
  327. parent::mediaWikiLogoPresentInitialScreen();
  328. $this->click( "link=set up the wiki" );
  329. $this->waitForPageToLoad( PAGE_LOAD_TIME );
  330. // 'Language' page
  331. parent::mediaWikiLogoPresent();
  332. parent::clickContinueButton();
  333. // 'Welcome to MediaWiki' page
  334. parent::mediaWikiLogoPresent();
  335. parent::clickContinueButton();
  336. // 'Connet to database' page
  337. parent::mediaWikiLogoPresent();
  338. $this->type("mysql_wgDBname", $databaseName );
  339. parent::clickContinueButton();
  340. // 'Database setting' page
  341. parent::mediaWikiLogoPresent();
  342. parent::clickContinueButton();
  343. // 'Name' page
  344. parent::mediaWikiLogoPresent();
  345. parent::completeNamePage();
  346. parent::clickContinueButton();
  347. // 'Options' page
  348. parent::mediaWikiLogoPresent();
  349. parent::clickContinueButton();
  350. // 'Install' page
  351. parent::mediaWikiLogoPresent();
  352. }
  353. public function testRightFramework() {
  354. parent::navigateLanguagePage();
  355. // Verfy right framework texts display
  356. $this->assertEquals( "Language",
  357. $this->getText( LINK_RIGHT_FRAMEWORK."li[1]" ));
  358. $this->assertEquals( "Existing wiki",
  359. $this->getText( LINK_RIGHT_FRAMEWORK."li[2]" ));
  360. $this->assertEquals( "Welcome to MediaWiki!",
  361. $this->getText( LINK_RIGHT_FRAMEWORK."li[3]" ));
  362. $this->assertEquals( "Connect to database",
  363. $this->getText( LINK_RIGHT_FRAMEWORK."li[4]" ));
  364. $this->assertEquals( "Upgrade existing installation",
  365. $this->getText( LINK_RIGHT_FRAMEWORK."li[5]" ));
  366. $this->assertEquals( "Database settings",
  367. $this->getText( LINK_RIGHT_FRAMEWORK."li[6]" ));
  368. $this->assertEquals( "Name",
  369. $this->getText( LINK_RIGHT_FRAMEWORK."li[7]" ));
  370. $this->assertEquals( "Options",
  371. $this->getText( LINK_RIGHT_FRAMEWORK."li[8]" ));
  372. $this->assertEquals( "Install",
  373. $this->getText( LINK_RIGHT_FRAMEWORK."li[9]" ));
  374. $this->assertEquals( "Complete!",
  375. $this->getText( LINK_RIGHT_FRAMEWORK."li[10]/span" ));
  376. }
  377. }