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