Use __DIR__ instead of dirname( __FILE__ )
[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
48 parent::navigateConnetToDatabasePage();
49
50 // Verify warning mesage for invalid database host
51 $this->type( "mysql_wgDBserver", INVALID_DB_HOST );
52 parent::clickContinueButton();
53 $this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (".INVALID_DB_HOST.").",
54 $this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
55 $this->assertEquals( "Check the host, username and password below and try again.",
56 $this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
57 // Verify warning message for the blank database host
58 $this->type( "mysql_wgDBserver", "" );
59 parent::clickContinueButton();
60 $this->assertEquals( "MySQL 4.0.14 or later is required, you have .",
61 $this->getText( LINK_DIV."div[2]/div[2]" ));
62
63 // Valid Database Host
64 $this->type( "mysql_wgDBserver", VALID_DB_HOST );
65
66 // Verify warning message for the invalid database name
67 $this->type( "mysql_wgDBname", INVALID_DB_NAME );
68 parent::clickContinueButton();
69 $this->assertEquals( "Invalid database name \"".INVALID_DB_NAME."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).",
70 $this->getText( LINK_DIV."div[2]/div[2]/p" ));
71
72 // Verify warning message for the blank database name
73 $this->type( "mysql_wgDBname", "");
74 parent::clickContinueButton();
75 $this->assertEquals( "You must enter a value for \"Database name\"",
76 $this->getText( LINK_DIV."div[2]/div[2]" ));
77
78 // valid Database name
79 $this->type( "mysql_wgDBname", VALID_DB_NAME);
80
81 // Verify warning message for the invalid databaase prefix
82 $this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX );
83 parent::clickContinueButton();
84 $this->assertEquals( "Invalid database prefix \"".INVALID_DB_PREFIX."\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).",
85 $this->getText( LINK_DIV."div[2]/div[2]" ));
86
87 // Valid Database prefix
88 $this->type( "mysql_wgDBprefix", VALID_DB_PREFIX );
89
90 // Verify warning message for the invalid database user name
91 $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME );
92 parent::clickContinueButton();
93 $this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: NO) (localhost).",
94 $this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
95 $this->assertEquals( "Check the host, username and password below and try again.",
96 $this->getText( LINK_DIV."div[2]/div[2]/p[2]"));
97
98 // Verify warning message for the blank database user name
99 $this->type( "mysql__InstallUser", "" );
100 parent::clickContinueButton();
101 $this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).",
102 $this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
103 $this->assertEquals( "Check the host, username and password below and try again.",
104 $this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
105
106 // Valid Database username
107 $this->type( "mysql__InstallUser", VALID_DB_USER_NAME );
108
109 // Verify warning message for the invalid password
110 $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD );
111 parent::clickContinueButton();
112
113 $this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).",
114 $this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
115 $this->assertEquals( "Check the host, username and password below and try again.",
116 $this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
117
118 // Verify warning message for the invalid username and password
119 $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME );
120 $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD );
121 parent::clickContinueButton();
122 $this->assertEquals( "DB connection error: Access denied for user '".INVALID_DB_USER_NAME."'@'localhost' (using password: YES) (localhost).",
123 $this->getText( LINK_DIV."div[2]/div[2]/p[1]" ));
124 $this->assertEquals( "Check the host, username and password below and try again.",
125 $this->getText( LINK_DIV."div[2]/div[2]/p[2]" ));
126
127 // Valid username and valid password
128 $this->type( "mysql__InstallUser", VALID_DB_USER_NAME );
129 $this->type( "mysql__InstallPassword", "" );
130 parent::clickContinueButton();
131
132 // successfully completes the 'Connect to database' page
133 $this->assertEquals( "Database settings",
134 $this->getText( LINK_DIV."h2" ));
135 }
136 }