diff --git a/libraries/config.default.php b/libraries/config.default.php index f7d4465974..8bfa21a80c 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -150,35 +150,35 @@ $cfg['Servers'][$i]['ssl'] = false; * * @global string $cfg['Servers'][$i]['ssl_key'] */ -$cfg['Servers'][$i]['ssl_key'] = NULL; +$cfg['Servers'][$i]['ssl_key'] = null; /** * Path to the cert file when using SSL for connecting to the MySQL server * * @global string $cfg['Servers'][$i]['ssl_cert'] */ -$cfg['Servers'][$i]['ssl_cert'] = NULL; +$cfg['Servers'][$i]['ssl_cert'] = null; /** * Path to the CA file when using SSL for connecting to the MySQL server * * @global string $cfg['Servers'][$i]['ssl_ca'] */ -$cfg['Servers'][$i]['ssl_ca'] = NULL; +$cfg['Servers'][$i]['ssl_ca'] = null; /** * Directory containing trusted SSL CA certificates in PEM format * * @global string $cfg['Servers'][$i]['ssl_ca_path'] */ -$cfg['Servers'][$i]['ssl_ca_path'] = NULL; +$cfg['Servers'][$i]['ssl_ca_path'] = null; /** * List of allowable ciphers for SSL connections to the MySQL server * * @global string $cfg['Servers'][$i]['ssl_ciphers'] */ -$cfg['Servers'][$i]['ssl_ciphers'] = NULL; +$cfg['Servers'][$i]['ssl_ciphers'] = null; /** * How to connect to MySQL server ('tcp' or 'socket') diff --git a/tbl_relation.php b/tbl_relation.php index 2dc55d9ad8..748fa40a6a 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -93,12 +93,12 @@ $multi_edit_columns_name = isset($_REQUEST['fields_name']) // u p d a t e s f o r I n t e r n a l r e l a t i o n s if (isset($_POST['destination_db']) && $cfgRelation['relwork']) { - PMA_handleUpdatesForInternalRelations( + PMA_handleUpdatesForInternalRelations( $_POST['destination_db'], $multi_edit_columns_name, $_POST['destination_table'], $_POST['destination_column'], $cfgRelation, $db, $table, isset($existrel) ? $existrel : null - ); + ); } // end if (updates for internal relations) $html_output = ''; diff --git a/test/classes/dbi/DBIMysql_test.php b/test/classes/dbi/DBIMysql_test.php index 20de3f0e6f..556edd6d17 100644 --- a/test/classes/dbi/DBIMysql_test.php +++ b/test/classes/dbi/DBIMysql_test.php @@ -85,18 +85,36 @@ class PMA_DBI_Mysql_Test extends PHPUnit_Framework_TestCase $this->markTestSkipped("Cannot redefine function"); } //FOR UT, we just test the right mysql client API is called - runkit_function_redefine('mysql_pconnect','','return "mysql_pconnect";'); - runkit_function_redefine('mysql_connect','','return "mysql_connect";'); - runkit_function_redefine('mysql_query','','return "mysql_query";'); - runkit_function_redefine('mysql_fetch_array','','return "mysql_fetch_array";'); - runkit_function_redefine('mysql_data_seek','','return "mysql_data_seek";'); - runkit_function_redefine('mysql_get_host_info','','return "mysql_get_host_info";'); - runkit_function_redefine('mysql_get_proto_info','','return "mysql_get_proto_info";'); - runkit_function_redefine('mysql_field_flags','','return "mysql_field_flags";'); - runkit_function_redefine('mysql_field_name','','return "mysql_field_name";'); - runkit_function_redefine('mysql_field_len','','return "mysql_field_len";'); - runkit_function_redefine('mysql_num_fields','','return "mysql_num_fields";'); - runkit_function_redefine('mysql_affected_rows','','return "mysql_affected_rows";'); + runkit_function_redefine('mysql_pconnect', '', 'return "mysql_pconnect";'); + runkit_function_redefine('mysql_connect', '', 'return "mysql_connect";'); + runkit_function_redefine('mysql_query', '', 'return "mysql_query";'); + runkit_function_redefine( + 'mysql_fetch_array', '', 'return "mysql_fetch_array";' + ); + runkit_function_redefine( + 'mysql_data_seek', '', 'return "mysql_data_seek";' + ); + runkit_function_redefine( + 'mysql_get_host_info', '', 'return "mysql_get_host_info";' + ); + runkit_function_redefine( + 'mysql_get_proto_info', '', 'return "mysql_get_proto_info";' + ); + runkit_function_redefine( + 'mysql_field_flags', '', 'return "mysql_field_flags";' + ); + runkit_function_redefine( + 'mysql_field_name', '', 'return "mysql_field_name";' + ); + runkit_function_redefine( + 'mysql_field_len', '', 'return "mysql_field_len";' + ); + runkit_function_redefine( + 'mysql_num_fields', '', 'return "mysql_num_fields";' + ); + runkit_function_redefine( + 'mysql_affected_rows', '', 'return "mysql_affected_rows";' + ); //test for fieldFlags $result = array("table1", "table2"); diff --git a/test/classes/dbi/DBIMysqli_test.php b/test/classes/dbi/DBIMysqli_test.php index 0554f48473..cb1087e03b 100644 --- a/test/classes/dbi/DBIMysqli_test.php +++ b/test/classes/dbi/DBIMysqli_test.php @@ -85,18 +85,36 @@ class PMA_DBI_Mysqli_Test extends PHPUnit_Framework_TestCase } //FOR UT, we just test the right mysql client API is called - runkit_function_redefine('mysqli_real_connect','','return "mysqli_real_connect";'); - runkit_function_redefine('mysqli_init','','return "mysqli_init";'); - runkit_function_redefine('mysqli_options','','return "mysqli_options";'); - runkit_function_redefine('mysqli_query','','return "mysqli_query";'); - runkit_function_redefine('mysqli_multi_query','','return "mysqli_multi_query";'); - runkit_function_redefine('mysqli_fetch_array','','return "mysqli_fetch_array";'); - runkit_function_redefine('mysqli_data_seek','','return "mysqli_data_seek";'); - runkit_function_redefine('mysqli_more_results','','return "mysqli_more_results";'); - runkit_function_redefine('mysqli_next_result','','return "mysqli_next_result";'); - runkit_function_redefine('mysqli_get_host_info','','return "mysqli_get_host_info";'); - runkit_function_redefine('mysqli_get_proto_info','','return "mysqli_get_proto_info";'); - runkit_function_redefine('mysqli_get_client_info','','return "mysqli_get_client_info";'); + runkit_function_redefine( + 'mysqli_real_connect', '', 'return "mysqli_real_connect";' + ); + runkit_function_redefine('mysqli_init', '', 'return "mysqli_init";'); + runkit_function_redefine('mysqli_options', '', 'return "mysqli_options";'); + runkit_function_redefine('mysqli_query', '', 'return "mysqli_query";'); + runkit_function_redefine( + 'mysqli_multi_query', '', 'return "mysqli_multi_query";' + ); + runkit_function_redefine( + 'mysqli_fetch_array', '', 'return "mysqli_fetch_array";' + ); + runkit_function_redefine( + 'mysqli_data_seek', '', 'return "mysqli_data_seek";' + ); + runkit_function_redefine( + 'mysqli_more_results', '', 'return "mysqli_more_results";' + ); + runkit_function_redefine( + 'mysqli_next_result', '', 'return "mysqli_next_result";' + ); + runkit_function_redefine( + 'mysqli_get_host_info', '', 'return "mysqli_get_host_info";' + ); + runkit_function_redefine( + 'mysqli_get_proto_info', '', 'return "mysqli_get_proto_info";' + ); + runkit_function_redefine( + 'mysqli_get_client_info', '', 'return "mysqli_get_client_info";' + ); $user = 'PMA_user'; $password = 'PMA_password'; diff --git a/test/libraries/PMA_relation_test.php b/test/libraries/PMA_relation_test.php index 9ff1cd5233..4baa8567aa 100644 --- a/test/libraries/PMA_relation_test.php +++ b/test/libraries/PMA_relation_test.php @@ -136,7 +136,7 @@ class PMA_Relation_Test extends PHPUnit_Framework_TestCase ); // $cfg['Servers'][$i]['table_info'] $result = "\$cfg['Servers'][\$i]['table_info'] ... " - . "" + . "" . "not OK"; $this->assertContains( $result, diff --git a/test/libraries/PMA_server_binlog_test.php b/test/libraries/PMA_server_binlog_test.php index 33d6739dd8..66d6304138 100644 --- a/test/libraries/PMA_server_binlog_test.php +++ b/test/libraries/PMA_server_binlog_test.php @@ -19,6 +19,7 @@ require_once 'libraries/Message.class.php'; require_once 'libraries/sanitizing.lib.php'; require_once 'libraries/sqlparser.lib.php'; require_once 'libraries/js_escape.lib.php'; +require_once 'libraries/database_interface.inc.php'; /** * PMA_ServerBinlog_Test class @@ -202,4 +203,65 @@ class PMA_ServerBinlog_Test extends PHPUnit_Framework_TestCase $html ); } + + /** + * Test for PMA_getAllLogItemInfo + * + * @return void + */ + public function testPMAGetAllLogItemInfo() + { + //Mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $fetchAssoc = array( + 'Info' => 'Info', + 'Log_name' => 'Log_name', + 'Pos' => 'Pos', + 'Event_type' => 'Event_type', + 'Server_id' => 'Server_id', + 'Orig_log_pos' => 'Orig_log_pos', + 'End_log_pos' => 'End_log_pos', + ); + $dbi->expects($this->at(0))->method('fetchAssoc') + ->will($this->returnValue($fetchAssoc)); + + $dbi->expects($this->at(1))->method('fetchAssoc') + ->will($this->returnValue(false)); + + $GLOBALS['dbi'] = $dbi; + $GLOBALS['cfg']['LimitChars'] = 2; + + $result = array(); + $dontlimitchars = ";"; + + $html = PMA_getAllLogItemInfo($result, $dontlimitchars); + $value = $fetchAssoc; + $this->assertContains( + $value['Log_name'], + $html + ); + $this->assertContains( + $value['Pos'], + $html + ); + $this->assertContains( + $value['Event_type'], + $html + ); + $this->assertContains( + $value['Server_id'], + $html + ); + $this->assertContains( + $value['Orig_log_pos'], + $html + ); + $this->assertContains( + htmlspecialchars($value['Info']), + $html + ); + } } diff --git a/test/libraries/PMA_server_databases_test.php b/test/libraries/PMA_server_databases_test.php index c65754c751..474cf1e8d5 100644 --- a/test/libraries/PMA_server_databases_test.php +++ b/test/libraries/PMA_server_databases_test.php @@ -245,4 +245,42 @@ class PMA_ServerDatabases_Test extends PHPUnit_Framework_TestCase $sort_order ); } + + /** + * Test for PMA_getHtmlForColumnOrder + * + * @return void + */ + public function testPMAGetHtmlForColumnOrder() + { + //Mock DBI + $dbi = $this->getMockBuilder('PMA_DatabaseInterface') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['dbi'] = $dbi; + + $column_order = array( + "first_database" => array( + 'format' => 'byte', + 'footer' => '10333', + ) + ); + $first_database = array( + "first_database" => "db1" + ); + $html = PMA_getHtmlForColumnOrder($column_order, $first_database); + $stat = $column_order["first_database" ]; + list($value, $unit) + = PMA_Util::formatByteDown($stat['footer'], 3, 1); + $this->assertContains( + $value, + $html + ); + $this->assertContains( + $unit, + $html + ); + + } } diff --git a/test/libraries/PMA_server_privileges_test.php b/test/libraries/PMA_server_privileges_test.php index 0e27d21de4..ffc6a5ee78 100644 --- a/test/libraries/PMA_server_privileges_test.php +++ b/test/libraries/PMA_server_privileges_test.php @@ -57,12 +57,22 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase $GLOBALS['cfg']['Server']['pmadb'] = 'pmadb'; $GLOBALS['cfg']['Server']['usergroups'] = 'usergroups'; $GLOBALS['cfg']['Server']['users'] = 'users'; + $GLOBALS['cfg']['ActionLinksMode'] = "both"; + $GLOBALS['cfg']['DefaultTabDatabase'] = 'db_structure.php'; + $GLOBALS['cfg']['QueryWindowHeight'] = 100; + $GLOBALS['cfg']['QueryWindowWidth'] = 100; + $GLOBALS['cfg']['PmaAbsoluteUri'] = "PmaAbsoluteUri"; + $GLOBALS['cfg']['DefaultTabTable'] = "db_structure.php"; + $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = "db_structure.php"; + $GLOBALS['cfg']['Confirm'] = "Confirm"; $GLOBALS['table'] = "table"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['server'] = 1; $GLOBALS['username'] = "pma_username"; + $GLOBALS['collation_connection'] = "collation_connection"; + $GLOBALS['text_dir'] = "text_dir"; //$_POST $_POST['pred_password'] = 'none'; @@ -70,6 +80,12 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); + $pmaconfig = $this->getMockBuilder('PMA_Config') + ->disableOriginalConstructor() + ->getMock(); + + $GLOBALS['PMA_Config'] = $pmaconfig; + //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface') ->disableOriginalConstructor() @@ -294,6 +310,38 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase } + /** + * Test for PMA_getHtmlForUserGroupDialog + * + * @return void + */ + public function testPMAGetHtmlForUserGroupDialog() + { + $username = "pma_username"; + $is_menuswork = true; + $_REQUEST['edit_user_group_dialog'] = "edit_user_group_dialog"; + $GLOBALS['is_ajax_request'] = false; + + //PMA_getHtmlForUserGroupDialog + $html = PMA_getHtmlForUserGroupDialog($username, $is_menuswork); + $this->assertContains( + '
$username); + $html_output = PMA_URL_getHiddenInputs($params); + $this->assertContains( + $html_output, + $html + ); + //__('User group') + $this->assertContains( + __('User group'), + $html + ); + } + /** * Test for PMA_getHtmlToChooseUserGroup * @@ -323,6 +371,118 @@ class PMA_ServerPrivileges_Test extends PHPUnit_Framework_TestCase ); } + /** + * Test for PMA_getHtmlForDisplayResourceLimits + * + * @return void + */ + public function testPMAGetHtmlForDisplayResourceLimits() + { + $row = array( + 'max_questions' => 'max_questions', + 'max_updates' => 'max_updates', + 'max_connections' => 'max_connections', + 'max_user_connections' => 'max_user_connections', + ); + + //PMA_getHtmlForDisplayResourceLimits + $html = PMA_getHtmlForDisplayResourceLimits($row); + $this->assertContains( + '' . __('Resource limits') . '', + $html + ); + $this->assertContains( + __('Note: Setting these options to 0 (zero) removes the limit.'), + $html + ); + $this->assertContains( + 'MAX QUERIES PER HOUR', + $html + ); + $this->assertContains( + $row['max_connections'], + $html + ); + $this->assertContains( + $row['max_updates'], + $html + ); + $this->assertContains( + $row['max_connections'], + $html + ); + $this->assertContains( + $row['max_user_connections'], + $html + ); + $this->assertContains( + __('Limits the number of simultaneous connections the user may have.'), + $html + ); + $this->assertContains( + __('Limits the number of simultaneous connections the user may have.'), + $html + ); + } + + /** + * Test for PMA_getSqlQueryForDisplayPrivTable + * + * @return void + */ + public function testPMAGetSqlQueryForDisplayPrivTable() + { + $username = "pma_username"; + $db = '*'; + $table = "pma_table"; + $hostname = "pma_hostname"; + + //$db == '*' + $ret = PMA_getSqlQueryForDisplayPrivTable( + $db, $table, $username, $hostname + ); + $sql = "SELECT * FROM `mysql`.`user`" + ." WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + ." AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "';"; + $this->assertEquals( + $sql, + $ret + ); + + //$table == '*' + $db = "pma_db"; + $table = "*"; + $ret = PMA_getSqlQueryForDisplayPrivTable( + $db, $table, $username, $hostname + ); + $sql = "SELECT * FROM `mysql`.`db`" + ." WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + ." AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "'" + ." AND '" . PMA_Util::unescapeMysqlWildcards($db) . "'" + ." LIKE `Db`;"; + $this->assertEquals( + $sql, + $ret + ); + + //$table == 'pma_table' + $db = "pma_db"; + $table = "pma_table"; + $ret = PMA_getSqlQueryForDisplayPrivTable( + $db, $table, $username, $hostname + ); + $sql = "SELECT `Table_priv`" + ." FROM `mysql`.`tables_priv`" + ." WHERE `User` = '" . PMA_Util::sqlAddSlashes($username) . "'" + ." AND `Host` = '" . PMA_Util::sqlAddSlashes($hostname) . "'" + ." AND `Db` = '" . PMA_Util::unescapeMysqlWildcards($db) . "'" + ." AND `Table_name` = '" . PMA_Util::sqlAddSlashes($table) . "';"; + $this->assertEquals( + $sql, + $ret + ); + } + /** * Test for PMA_getDataForChangeOrCopyUser *