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