1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
<?php
/**
* MediaWikiErrorsConnectToDatabasePageTestCase
*
* @file
* @ingroup Maintenance
* Copyright (C) 2010 Nadeesha Weerasinghe <nadeesha@calcey.com>
* http://www.calcey.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @addtogroup Maintenance
*
*/
require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' );
/**
* Test Case ID : 09 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
* Test Case Name : Invalid/ blank values for fields in 'Connect to database' page.
* Version : MediaWiki 1.18alpha
*/
class MediaWikiErrorsConnectToDatabasePageTestCase extends MediaWikiInstallationCommonFunction {
function setUp() {
parent::setUp();
}
// Verify warning messages for the 'Connet to database' page
public function testErrorsConnectToDatabasePage() {
parent::navigateConnetToDatabasePage();
// Verify warning mesage for invalid database host
$this->type( "mysql_wgDBserver", INVALID_DB_HOST );
parent::clickContinueButton();
$this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (".INVALID_DB_HOST.").",
$this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
$this->assertEquals( "Check the host, username and password below and try again.",
$this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
// Verify warning message for the blank database host
$this->type( "mysql_wgDBserver", "" );
parent::clickContinueButton();
$this->assertEquals( "MySQL 4.0.14 or later is required, you have .",
$this->getText( LINK_DIV."div[2]/div[2]" ));
// Valid Database Host
$this->type( "mysql_wgDBserver", VALID_DB_HOST );
// Verify warning message for the invalid database name
$this->type( "mysql_wgDBname", INVALID_DB_NAME );
parent::clickContinueButton();
$this->assertEquals( "Invalid database name \"".INVALID_DB_NAME."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).",
$this->getText( LINK_DIV."div[2]/div[2]/p" ));
// Verify warning message for the blank database name
$this->type( "mysql_wgDBname", "");
parent::clickContinueButton();
$this->assertEquals( "You must enter a value for \"Database name\"",
$this->getText( LINK_DIV."div[2]/div[2]" ));
// valid Database name
$this->type( "mysql_wgDBname", VALID_DB_NAME);
// Verify warning message for the invalid databaase prefix
$this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX );
parent::clickContinueButton();
$this->assertEquals( "Invalid database prefix \"".INVALID_DB_PREFIX."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).",
$this->getText( LINK_DIV."div[2]/div[2]" ));
// Valid Database prefix
$this->type( "mysql_wgDBprefix", VALID_DB_PREFIX );
// Verify warning message for the invalid database user name
$this->type( "mysql__InstallUser", INVALID_DB_USER_NAME );
parent::clickContinueButton();
$this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: NO) (localhost).",
$this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
$this->assertEquals( "Check the host, username and password below and try again.",
$this->getText( LINK_DIV."div[2]/div[2]/p[2]"));
// Verify warning message for the blank database user name
$this->type( "mysql__InstallUser", "" );
parent::clickContinueButton();
$this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).",
$this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
$this->assertEquals( "Check the host, username and password below and try again.",
$this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
// Valid Database username
$this->type( "mysql__InstallUser", VALID_DB_USER_NAME );
// Verify warning message for the invalid password
$this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD );
parent::clickContinueButton();
$this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).",
$this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
$this->assertEquals( "Check the host, username and password below and try again.",
$this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
// Verify warning message for the invalid username and password
$this->type( "mysql__InstallUser", INVALID_DB_USER_NAME );
$this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD );
parent::clickContinueButton();
$this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: YES) (localhost).",
$this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
$this->assertEquals( "Check the host, username and password below and try again.",
$this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
// Valid username and valid password
$this->type( "mysql__InstallUser", VALID_DB_USER_NAME );
$this->type( "mysql__InstallPassword", "" );
parent::clickContinueButton();
// successfully completes the 'Connect to database' page
$this->assertEquals( "Database settings",
$this->getText( LINK_DIV."h2" ));
}
}
|