MediaWiki
REL1_21
|
00001 <?php 00027 require_once ( __DIR__ . '/MediaWikiInstallationCommonFunction.php' ); 00028 00035 class MediaWikiErrorsConnectToDatabasePageTestCase extends MediaWikiInstallationCommonFunction { 00036 00037 function setUp() { 00038 parent::setUp(); 00039 } 00040 00041 // Verify warning messages for the 'Connet to database' page 00042 public function testErrorsConnectToDatabasePage() { 00043 parent::navigateConnetToDatabasePage(); 00044 00045 // Verify warning mesage for invalid database host 00046 $this->type( "mysql_wgDBserver", INVALID_DB_HOST ); 00047 parent::clickContinueButton(); 00048 $this->assertEquals( "DB connection error: php_network_getaddresses: getaddrinfo failed: No such host is known. (" . INVALID_DB_HOST . ").", 00049 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); 00050 $this->assertEquals( "Check the host, username and password below and try again.", 00051 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); 00052 // Verify warning message for the blank database host 00053 $this->type( "mysql_wgDBserver", "" ); 00054 parent::clickContinueButton(); 00055 $this->assertEquals( "MySQL 4.0.14 or later is required, you have .", 00056 $this->getText( LINK_DIV . "div[2]/div[2]" ) ); 00057 00058 // Valid Database Host 00059 $this->type( "mysql_wgDBserver", VALID_DB_HOST ); 00060 00061 // Verify warning message for the invalid database name 00062 $this->type( "mysql_wgDBname", INVALID_DB_NAME ); 00063 parent::clickContinueButton(); 00064 $this->assertEquals( "Invalid database name \"" . INVALID_DB_NAME . "\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", 00065 $this->getText( LINK_DIV . "div[2]/div[2]/p" ) ); 00066 00067 // Verify warning message for the blank database name 00068 $this->type( "mysql_wgDBname", "" ); 00069 parent::clickContinueButton(); 00070 $this->assertEquals( "You must enter a value for \"Database name\"", 00071 $this->getText( LINK_DIV . "div[2]/div[2]" ) ); 00072 00073 // valid Database name 00074 $this->type( "mysql_wgDBname", VALID_DB_NAME ); 00075 00076 // Verify warning message for the invalid databaase prefix 00077 $this->type( "mysql_wgDBprefix", INVALID_DB_PREFIX ); 00078 parent::clickContinueButton(); 00079 $this->assertEquals( "Invalid database prefix \"" . INVALID_DB_PREFIX . "\". Use only ASCII letters (a-z, A-Z), numbers (0-9) and underscores (_).", 00080 $this->getText( LINK_DIV . "div[2]/div[2]" ) ); 00081 00082 // Valid Database prefix 00083 $this->type( "mysql_wgDBprefix", VALID_DB_PREFIX ); 00084 00085 // Verify warning message for the invalid database user name 00086 $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); 00087 parent::clickContinueButton(); 00088 $this->assertEquals( "DB connection error: Access denied for user '" . INVALID_DB_USER_NAME . "'@'localhost' (using password: NO) (localhost).", 00089 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); 00090 $this->assertEquals( "Check the host, username and password below and try again.", 00091 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); 00092 00093 // Verify warning message for the blank database user name 00094 $this->type( "mysql__InstallUser", "" ); 00095 parent::clickContinueButton(); 00096 $this->assertEquals( "DB connection error: Access denied for user 'SYSTEM'@'localhost' (using password: NO) (localhost).", 00097 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); 00098 $this->assertEquals( "Check the host, username and password below and try again.", 00099 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); 00100 00101 // Valid Database username 00102 $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); 00103 00104 // Verify warning message for the invalid password 00105 $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); 00106 parent::clickContinueButton(); 00107 00108 $this->assertEquals( "DB connection error: Access denied for user 'root'@'localhost' (using password: YES) (localhost).", 00109 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); 00110 $this->assertEquals( "Check the host, username and password below and try again.", 00111 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); 00112 00113 // Verify warning message for the invalid username and password 00114 $this->type( "mysql__InstallUser", INVALID_DB_USER_NAME ); 00115 $this->type( "mysql__InstallPassword", INVALID_DB_PASSWORD ); 00116 parent::clickContinueButton(); 00117 $this->assertEquals( "DB connection error: Access denied for user '" . INVALID_DB_USER_NAME . "'@'localhost' (using password: YES) (localhost).", 00118 $this->getText( LINK_DIV . "div[2]/div[2]/p[1]" ) ); 00119 $this->assertEquals( "Check the host, username and password below and try again.", 00120 $this->getText( LINK_DIV . "div[2]/div[2]/p[2]" ) ); 00121 00122 // Valid username and valid password 00123 $this->type( "mysql__InstallUser", VALID_DB_USER_NAME ); 00124 $this->type( "mysql__InstallPassword", "" ); 00125 parent::clickContinueButton(); 00126 00127 // successfully completes the 'Connect to database' page 00128 $this->assertEquals( "Database settings", 00129 $this->getText( LINK_DIV . "h2" ) ); 00130 } 00131 }