tests: mock parser tests file access
[mediawiki.git] / tests / selenium / installer / MediaWikiErrorsConnectToDatabasePageTestCase.php
blob37f5af2fc842856ca583ccccc438cf5b2fd8ea86
1 <?php
2 /**
3 * MediaWikiErrorsConnectToDatabasePageTestCase
5 * @file
6 * @ingroup Maintenance
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
27 require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' );
29 /**
30 * Test Case ID : 09 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
31 * Test Case Name : Invalid/ blank values for fields in 'Connect to database' page.
32 * Version : MediaWiki 1.18alpha
35 class MediaWikiErrorsConnectToDatabasePageTestCase extends MediaWikiInstallationCommonFunction {
37 function setUp() {
38 parent::setUp();
41 // Verify warning messages for the 'Connet to database' page
42 public function testErrorsConnectToDatabasePage() {
43 parent::navigateConnetToDatabasePage();
45 // Verify warning mesage for invalid database host
46 $this->type( "mysql_wgDBserver", INVALID_DB_HOST );
47 parent::clickContinueButton();
48 $this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (" . INVALID_DB_HOST . ").",
49 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) );
50 $this->assertEquals( "Check the host, username and password below and try again.",
51 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) );
52 // Verify warning message for the blank database host
53 $this->type( "mysql_wgDBserver", "" );
54 parent::clickContinueButton();
55 $this->assertEquals( "MySQL 4.0.14 or later is required, you have .",
56 $this->getText( LINK_DIV . "div[2]/div[2]" ) );
58 // Valid Database Host
59 $this->type( "mysql_wgDBserver", VALID_DB_HOST );
61 // Verify warning message for the invalid database name
62 $this->type( "mysql_wgDBname", INVALID_DB_NAME );
63 parent::clickContinueButton();
64 $this->assertEquals( "Invalid database name \"" . INVALID_DB_NAME . "\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).",
65 $this->getText( LINK_DIV . "div[2]/div[2]/p" ) );
67 // Verify warning message for the blank database name
68 $this->type( "mysql_wgDBname", "" );
69 parent::clickContinueButton();
70 $this->assertEquals( "You must enter a value for \"Database name\"",
71 $this->getText( LINK_DIV . "div[2]/div[2]" ) );
73 // valid Database name
74 $this->type( "mysql_wgDBname", VALID_DB_NAME );
76 // Verify warning message for the invalid databaase prefix
77 $this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX );
78 parent::clickContinueButton();
79 $this->assertEquals( "Invalid database prefix \"" . INVALID_DB_PREFIX . "\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).",
80 $this->getText( LINK_DIV . "div[2]/div[2]" ) );
82 // Valid Database prefix
83 $this->type( "mysql_wgDBprefix", VALID_DB_PREFIX );
85 // Verify warning message for the invalid database user name
86 $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME );
87 parent::clickContinueButton();
88 $this->assertEquals( "DB connection error: Access denied for user '" . INVALID_DB_USER_NAME . "'@'localhost' (using password: NO) (localhost).",
89 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) );
90 $this->assertEquals( "Check the host, username and password below and try again.",
91 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) );
93 // Verify warning message for the blank database user name
94 $this->type( "mysql__InstallUser", "" );
95 parent::clickContinueButton();
96 $this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).",
97 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) );
98 $this->assertEquals( "Check the host, username and password below and try again.",
99 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) );
101 // Valid Database username
102 $this->type( "mysql__InstallUser", VALID_DB_USER_NAME );
104 // Verify warning message for the invalid password
105 $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD );
106 parent::clickContinueButton();
108 $this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).",
109 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) );
110 $this->assertEquals( "Check the host, username and password below and try again.",
111 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) );
113 // Verify warning message for the invalid username and password
114 $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME );
115 $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD );
116 parent::clickContinueButton();
117 $this->assertEquals( "DB connection error: Access denied for user '" . INVALID_DB_USER_NAME . "'@'localhost' (using password: YES) (localhost).",
118 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) );
119 $this->assertEquals( "Check the host, username and password below and try again.",
120 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) );
122 // Valid username and valid password
123 $this->type( "mysql__InstallUser", VALID_DB_USER_NAME );
124 $this->type( "mysql__InstallPassword", "" );
125 parent::clickContinueButton();
127 // successfully completes the 'Connect to database' page
128 $this->assertEquals( "Database settings",
129 $this->getText( LINK_DIV . "h2" ) );