diff --git a/js/server_privileges.js b/js/server_privileges.js index 8a643c7625..8dacea8ba4 100644 --- a/js/server_privileges.js +++ b/js/server_privileges.js @@ -166,7 +166,7 @@ function addUser($form) /** * Unbind all event handlers before tearing down a page */ -AJAX.registerTeardown('server_privileges.js', function() { +AJAX.registerTeardown('server_privileges.js', function () { $("#fieldset_add_user_login input[name='username']").die("focusout"); $("#fieldset_add_user a.ajax").die("click"); $('form[name=usersForm]').unbind('submit'); @@ -185,7 +185,7 @@ AJAX.registerOnload('server_privileges.js', function () { /** * Display a warning if there is already a user by the name entered as the username. */ - $("#fieldset_add_user_login input[name='username']").live("focusout", function() { + $("#fieldset_add_user_login input[name='username']").live("focusout", function () { var username = $(this).val(); var $warning = $("#user_exists_warning"); if ($("#select_pred_username").val() == 'userdefined' && username != '') { @@ -196,7 +196,7 @@ AJAX.registerOnload('server_privileges.js', function () { 'validate_username' : true, 'username' : username }; - $.get(href, params, function(data) { + $.get(href, params, function (data) { if (data.user_exists) { $warning.show(); } else { diff --git a/js/tbl_structure.js b/js/tbl_structure.js index 9ea8d5f1bf..3f45583d2f 100644 --- a/js/tbl_structure.js +++ b/js/tbl_structure.js @@ -54,7 +54,7 @@ AJAX.registerOnload('tbl_structure.js', function () { /** *Ajax action for submitting the "Column Change" and "Add Column" form */ - $(".append_fields_form.ajax").die().live('submit', function(event) { + $(".append_fields_form.ajax").die().live('submit', function (event) { event.preventDefault(); /** * @var the_form object referring to the export form @@ -73,7 +73,7 @@ AJAX.registerOnload('tbl_structure.js', function () { PMA_prepareForAjaxRequest($form); //User wants to submit the form $msg = PMA_ajaxShowMessage(); - $.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function(data) { + $.post($form.attr('action'), $form.serialize() + '&do_save_data=1', function (data) { if ($("#sqlqueryresults").length != 0) { $("#sqlqueryresults").remove(); } else if ($(".error:not(.tab)").length != 0) { diff --git a/libraries/dbi/DBIDummy.class.php b/libraries/dbi/DBIDummy.class.php index a7809f33a3..8eedafe559 100644 --- a/libraries/dbi/DBIDummy.class.php +++ b/libraries/dbi/DBIDummy.class.php @@ -255,6 +255,27 @@ $GLOBALS['dummy_queries'] = array( 'query' => "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.`SCHEMA_PRIVILEGES` WHERE GRANTEE='''pma_test''@''localhost''' AND PRIVILEGE_TYPE='TRIGGER' AND TABLE_SCHEMA='pma'", 'result' => array(), ), + array( + 'query' => 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1', + 'columns' => array('DEFAULT_COLLATION_NAME'), + 'result' => array( + array('utf8_general_ci') + ) + ), + array( + 'query' => 'SELECT DEFAULT_COLLATION_NAME FROM data_dictionary.SCHEMAS WHERE SCHEMA_NAME = \'pma_test\' LIMIT 1', + 'columns' => array('DEFAULT_COLLATION_NAME'), + 'result' => array( + array('utf8_general_ci_pma_drizzle') + ) + ), + array( + 'query' => 'SHOW VARIABLES LIKE \'collation_database\'', + 'columns' => array('variable_name', 'variable_value'), + 'result' => array( + array('foo', 'bar'), + ) + ), array( 'query' => "SHOW TABLES FROM `phpmyadmin`", 'result' => array(), @@ -649,4 +670,4 @@ class PMA_DBI_Dummy implements PMA_DBI_Extension return ''; } } -?> +?> \ No newline at end of file diff --git a/po/es.po b/po/es.po index 1457469b0d..318923b8e4 100644 --- a/po/es.po +++ b/po/es.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-12 09:39+0200\n" -"PO-Revision-Date: 2013-06-04 17:59+0200\n" +"PO-Revision-Date: 2013-06-12 18:24+0200\n" "Last-Translator: Matías Bellone \n" -"Language-Team: Spanish \n" +"Language-Team: Spanish " +"\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -4162,7 +4162,7 @@ msgstr "Permitir a los usuarios personalizar este valor" #: libraries/config/FormDisplay.tpl.php:392 msgid "Apply" -msgstr "" +msgstr "Aplicar" #: libraries/config/FormDisplay.tpl.php:394 libraries/insert_edit.lib.php:1551 #: libraries/schema/User_Schema.class.php:554 prefs_manage.php:326 @@ -6390,19 +6390,19 @@ msgstr "ZIP" #: libraries/config/messages.inc.php:531 msgid "Enter your public key for your domain reCaptcha service" -msgstr "" +msgstr "Ingrese su llave pública para el servicio reCaptcha de su dominio" #: libraries/config/messages.inc.php:532 msgid "Public key for reCaptcha" -msgstr "" +msgstr "Llave púlica para reCaptcha" #: libraries/config/messages.inc.php:533 msgid "Enter your private key for your domain reCaptcha service" -msgstr "" +msgstr "Ingrese su llave privada para el servicio reCaptcha de su dominio" #: libraries/config/messages.inc.php:534 msgid "Private key for reCaptcha" -msgstr "" +msgstr "Llave privada para reCaptcha" #: libraries/config/setup.forms.php:41 msgid "Config authentication" @@ -7997,11 +7997,11 @@ msgstr "Elección del servidor:" #: libraries/plugins/auth/AuthenticationCookie.class.php:386 msgid "Entered captcha is wrong, try again!" -msgstr "" +msgstr "El captcha ingresado es incorrecto, ¡intente nuevamente!" #: libraries/plugins/auth/AuthenticationCookie.class.php:395 msgid "Please enter correct captcha!" -msgstr "" +msgstr "¡Ingrese el captcha correcto!" #: libraries/plugins/auth/AuthenticationCookie.class.php:657 #: libraries/plugins/auth/AuthenticationSignon.class.php:249 @@ -8499,10 +8499,9 @@ msgstr "" "problema e intente nuevamente." #: libraries/plugins/import/ImportOds.class.php:182 -#, fuzzy #| msgid "OpenDocument Spreadsheet" msgid "Could not parse OpenDocument Spreasheet!" -msgstr "Hoja de cálculo Open Document" +msgstr "¡No se pudo procesar la hoja de cálculo Open Document!" #: libraries/plugins/import/ImportShp.class.php:53 msgid "ESRI Shape File" diff --git a/po/fr.po b/po/fr.po index 588b435165..fe89510992 100644 --- a/po/fr.po +++ b/po/fr.po @@ -4,10 +4,9 @@ msgstr "" "Project-Id-Version: phpMyAdmin-docs 4.0.0-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-12 09:39+0200\n" -"PO-Revision-Date: 2013-06-05 13:51+0200\n" +"PO-Revision-Date: 2013-06-12 16:43+0200\n" "Last-Translator: Marc Delisle \n" -"Language-Team: French \n" +"Language-Team: French \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -4139,7 +4138,7 @@ msgstr "Permettre aux utilisateurs de personnaliser cette valeur" #: libraries/config/FormDisplay.tpl.php:392 msgid "Apply" -msgstr "" +msgstr "Appliquer" #: libraries/config/FormDisplay.tpl.php:394 libraries/insert_edit.lib.php:1551 #: libraries/schema/User_Schema.class.php:554 prefs_manage.php:326 @@ -6345,19 +6344,19 @@ msgstr "ZIP" #: libraries/config/messages.inc.php:531 msgid "Enter your public key for your domain reCaptcha service" -msgstr "" +msgstr "Saisissez la clé publique du service reCaptcha pour votre domaine" #: libraries/config/messages.inc.php:532 msgid "Public key for reCaptcha" -msgstr "" +msgstr "Clé publique pour reCaptcha" #: libraries/config/messages.inc.php:533 msgid "Enter your private key for your domain reCaptcha service" -msgstr "" +msgstr "Saisissez la clé privée du service reCaptcha pour votre domaine" #: libraries/config/messages.inc.php:534 msgid "Private key for reCaptcha" -msgstr "" +msgstr "Clé privée pour reCaptcha" #: libraries/config/setup.forms.php:41 msgid "Config authentication" @@ -7935,11 +7934,11 @@ msgstr "Choix du serveur : " #: libraries/plugins/auth/AuthenticationCookie.class.php:386 msgid "Entered captcha is wrong, try again!" -msgstr "" +msgstr "Erreur, essayez à nouveau !" #: libraries/plugins/auth/AuthenticationCookie.class.php:395 msgid "Please enter correct captcha!" -msgstr "" +msgstr "Veuillez saisir le captcha correct !" #: libraries/plugins/auth/AuthenticationCookie.class.php:657 #: libraries/plugins/auth/AuthenticationSignon.class.php:249 @@ -8435,10 +8434,9 @@ msgstr "" "et essayer à nouveau." #: libraries/plugins/import/ImportOds.class.php:182 -#, fuzzy #| msgid "OpenDocument Spreadsheet" msgid "Could not parse OpenDocument Spreasheet!" -msgstr "Tableur OpenDocument" +msgstr "Analyse incorrecte du tableur OpenDocument !" #: libraries/plugins/import/ImportShp.class.php:53 msgid "ESRI Shape File" diff --git a/po/nl.po b/po/nl.po index 617a38ce2f..9c72fa8e5e 100644 --- a/po/nl.po +++ b/po/nl.po @@ -4,7 +4,7 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-12 09:39+0200\n" -"PO-Revision-Date: 2013-06-05 13:42+0200\n" +"PO-Revision-Date: 2013-06-12 14:52+0200\n" "Last-Translator: Dieter Adriaenssens \n" "Language-Team: Dutch \n" "Language: nl\n" @@ -8444,10 +8444,9 @@ msgstr "" "probeer opnieuw." #: libraries/plugins/import/ImportOds.class.php:182 -#, fuzzy #| msgid "OpenDocument Spreadsheet" msgid "Could not parse OpenDocument Spreasheet!" -msgstr "OpenDocument-rekenblad" +msgstr "Kon OpenDocument-rekenblad niet inlezen!" #: libraries/plugins/import/ImportShp.class.php:53 msgid "ESRI Shape File" diff --git a/po/sl.po b/po/sl.po index 3a1fc981e5..11c576b287 100644 --- a/po/sl.po +++ b/po/sl.po @@ -4,10 +4,10 @@ msgstr "" "Project-Id-Version: phpMyAdmin 4.1-dev\n" "Report-Msgid-Bugs-To: phpmyadmin-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2013-06-12 09:39+0200\n" -"PO-Revision-Date: 2013-06-05 21:28+0200\n" +"PO-Revision-Date: 2013-06-12 18:46+0200\n" "Last-Translator: Domen \n" -"Language-Team: Slovenian \n" +"Language-Team: Slovenian " +"\n" "Language: sl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -4117,7 +4117,7 @@ msgstr "Dovoli uporabnikom prilagajati to vrednost" #: libraries/config/FormDisplay.tpl.php:392 msgid "Apply" -msgstr "" +msgstr "Uveljavi" #: libraries/config/FormDisplay.tpl.php:394 libraries/insert_edit.lib.php:1551 #: libraries/schema/User_Schema.class.php:554 prefs_manage.php:326 @@ -6306,7 +6306,7 @@ msgstr "" #: libraries/config/messages.inc.php:532 msgid "Public key for reCaptcha" -msgstr "" +msgstr "Javni ključ za reCaptcha" #: libraries/config/messages.inc.php:533 msgid "Enter your private key for your domain reCaptcha service" @@ -6314,7 +6314,7 @@ msgstr "" #: libraries/config/messages.inc.php:534 msgid "Private key for reCaptcha" -msgstr "" +msgstr "Zasebni ključ za reCaptcha" #: libraries/config/setup.forms.php:41 msgid "Config authentication" @@ -7883,11 +7883,11 @@ msgstr "Izbira strežnika:" #: libraries/plugins/auth/AuthenticationCookie.class.php:386 msgid "Entered captcha is wrong, try again!" -msgstr "" +msgstr "Vnesena captcha je napačna; poskusite znova!" #: libraries/plugins/auth/AuthenticationCookie.class.php:395 msgid "Please enter correct captcha!" -msgstr "" +msgstr "Prosimo, vnesite pravilno captcho!" #: libraries/plugins/auth/AuthenticationCookie.class.php:657 #: libraries/plugins/auth/AuthenticationSignon.class.php:249 @@ -8379,10 +8379,9 @@ msgstr "" "težave in poskusite znova." #: libraries/plugins/import/ImportOds.class.php:182 -#, fuzzy #| msgid "OpenDocument Spreadsheet" msgid "Could not parse OpenDocument Spreasheet!" -msgstr "Preglednica OpenDocument" +msgstr "Ne morem razčleniti preglednice OpenDocument!" #: libraries/plugins/import/ImportShp.class.php:53 msgid "ESRI Shape File" diff --git a/test/libraries/PMA_charset_conversion_test.php b/test/libraries/PMA_charset_conversion_test.php new file mode 100644 index 0000000000..15be6c8958 --- /dev/null +++ b/test/libraries/PMA_charset_conversion_test.php @@ -0,0 +1,72 @@ +assertEquals( + 'test', + PMA_convertString('UTF-8', 'UTF-8', 'test') + ); + + // 6 represents an arbitrary value for testing the default case + $GLOBALS['PMA_recoding_engine'] = 6; + $this->assertEquals( + 'test', + PMA_convertString('UTF-8', 'flat', 'test') + ); + + // TODO: remove function_exists if recode_string exists on server + if (@function_exists('recode_string')) { + $GLOBALS['PMA_recoding_engine'] = PMA_CHARSET_RECODE; + $this->assertEquals( + 'Only That ecole & Can Be My Blame', + PMA_convertString( + 'UTF-8', 'flat', 'Only That école & Can Be My Blame' + ) + ); + } + + $GLOBALS['PMA_recoding_engine'] = PMA_CHARSET_ICONV; + $GLOBALS['cfg']['IconvExtraParams'] = '//TRANSLIT'; + $this->assertEquals( + "This is the Euro symbol 'EUR'.", + PMA_convertString( + 'UTF-8', 'ISO-8859-1', "This is the Euro symbol '€'." + ) + ); + + $GLOBALS['cfg']['IconvExtraParams'] = '//IGNORE'; + $GLOBALS['PMA_recoding_engine'] = PMA_CHARSET_ICONV_AIX; + $this->assertEquals( + "This is the Euro symbol ''.", + PMA_convertString( + 'UTF-8', 'ISO-8859-1', "This is the Euro symbol '€'." + ) + ); + } +} +?> diff --git a/test/libraries/PMA_iconv_wrapper_test.php b/test/libraries/PMA_iconv_wrapper_test.php new file mode 100644 index 0000000000..22be08e6a4 --- /dev/null +++ b/test/libraries/PMA_iconv_wrapper_test.php @@ -0,0 +1,76 @@ +assertEquals( + iconv($in_charset_mapped, $out_charset_mapped, $str), + PMA_aix_iconv_wrapper($in_charset, $out_charset, $str) + ); + } + + + /** + * Data provider for testIconvWrapper + * + * @return array data for testIconvWrapper test case + */ + public function iconvDataProvider() + { + return array( + array( + 'UTF-8', + 'ISO-8859-1//IGNORE', + 'UTF-8', + 'ISO-8859-1//IGNORE', + 'Euro Symbol: €' + ), + array( + 'UTF-8', + 'ISO-8859-1//IGNORE//TRANSLIT', + 'UTF-8', + 'ISO-8859-1//IGNORE', + 'Euro Symbol: €' + ), + array('UTF-8', + 'ISO-8859-9', + 'UTF-8', + 'ISO8859-9', + 'Testing "string"' + ) + ); + } +} +?> diff --git a/test/libraries/PMA_kanji-encoding_test.php b/test/libraries/PMA_kanji-encoding_test.php new file mode 100644 index 0000000000..fcbdec9401 --- /dev/null +++ b/test/libraries/PMA_kanji-encoding_test.php @@ -0,0 +1,170 @@ +assertTrue(PMA_Kanji_checkEncoding()); + $this->assertEquals($expected, $GLOBALS['kanji_encoding_list']); + } + + /** + * Data provider for testPMA_Kanji_checkEncoding + * + * @return array Test data + */ + public function checkEncodingData() + { + return array( + array('UTF-8', 'ASCII,SJIS,EUC-JP,JIS'), + array('EUC-JP', 'ASCII,EUC-JP,SJIS,JIS') + ); + } + + /** + * Test for PMA_Kanji_changeOrder + * + * @param string $kanji_test_list current list + * @param string $expected expected list + * + * @return void + * @test + * @dataProvider changeOrderData + */ + public function testChangeOrder($kanji_test_list, $expected) + { + $GLOBALS['kanji_encoding_list'] = $kanji_test_list; + $this->assertTrue(PMA_Kanji_changeOrder()); + $this->assertEquals($expected, $GLOBALS['kanji_encoding_list']); + } + + /** + * Data Provider for testPMA_Kanji_changeOrder + * + * @return array Test data + */ + public function changeOrderData() + { + return array( + array('ASCII,SJIS,EUC-JP,JIS', 'ASCII,EUC-JP,SJIS,JIS'), + array('ASCII,EUC-JP,SJIS,JIS', 'ASCII,SJIS,EUC-JP,JIS') + ); + } + + /** + * Test for PMA_Kanji_strConv + * + * @return void + * @test + */ + public function testStrConv() + { + $this->assertEquals( + 'test', + PMA_Kanji_strConv('test', '', '') + ); + + $GLOBALS['kanji_encoding_list'] = 'ASCII,SJIS,EUC-JP,JIS'; + + $this->assertEquals( + 'test è', + PMA_Kanji_strConv('test è', '', '') + ); + + $this->assertEquals( + mb_convert_encoding('test è', 'ASCII', 'SJIS'), + PMA_Kanji_strConv('test è', 'ASCII', '') + ); + + $this->assertEquals( + mb_convert_kana('全角', 'KV', 'SJIS'), + PMA_Kanji_strConv('全角', '', 'kana') + ); + } + + + /** + * Test for PMA_Kanji_fileConv + * + * @return void + * @test + */ + public function testFileConv() + { + $file_str = "教育漢字常用漢字"; + $filename = 'test.kanji'; + $file = fopen($filename, 'w'); + fputs($file, $file_str); + fclose($file); + $GLOBALS['kanji_encoding_list'] = 'ASCII,EUC-JP,SJIS,JIS'; + + $result = PMA_Kanji_fileConv($filename, 'JIS', 'kana'); + + $string = file_get_contents($result); + PMA_Kanji_changeOrder(); + $expected = PMA_Kanji_strConv($file_str, 'JIS', 'kana'); + PMA_Kanji_changeOrder(); + $this->assertEquals($string, $expected); + unlink($result); + } + + + /** + * Test for PMA_Kanji_encodingForm + * + * @return void + * @test + */ + public function testEncodingForm() + { + $actual = PMA_Kanji_encodingForm(); + $this->assertContains( + 'assertContains( + 'type="radio" name="knjenc"', + $actual + ); + $this->assertContains( + '', + $actual + ); + $this->assertContains( + '', + $actual + ); + $this->assertContains( + '', + $actual + ); + } +} +?> diff --git a/test/libraries/PMA_mysql_charsets_test.php b/test/libraries/PMA_mysql_charsets_test.php new file mode 100644 index 0000000000..4d817abac9 --- /dev/null +++ b/test/libraries/PMA_mysql_charsets_test.php @@ -0,0 +1,291 @@ +markTestSkipped( + 'Cannot redefine constant/function - missing APD or/and runkit extension' + ); + } else { + if (defined('PMA_DRIZZLE')) { + runkit_constant_redefine('PMA_DRIZZLE', $drizzle); + } else { + define('PMA_DRIZZLE', $drizzle); + } + + $this->assertEquals( + $expected, + PMA_generateCharsetQueryPart($collation) + ); + } + } + + /** + * Data Provider for testPMA_generateCharsetQueryPart + * + * @return array test data + */ + public function charsetQueryData() + { + return array( + array(false, "a_b_c_d", " CHARACTER SET a COLLATE a_b_c_d"), + array(false, "a_", " CHARACTER SET a COLLATE a_"), + array(false, "a", " CHARACTER SET a"), + array(true, "a_b_c_d", " COLLATE a_b_c_d") + ); + } + + + /** + * Test for PMA_getDbCollation + * + * @return void + * @test + */ + public function testGetDbCollation() + { + if (! function_exists("runkit_constant_redefine")) { + $this->markTestSkipped( + 'Cannot redefine constant/function - missing APD or/and runkit extension' + ); + } else { + // test case for system schema + $this->assertEquals( + 'utf8_general_ci', + PMA_getDbCollation("information_schema") + ); + + // test case with no pma drizzle + if (defined('PMA_DRIZZLE')) { + runkit_constant_redefine('PMA_DRIZZLE', false); + } else { + define('PMA_DRIZZLE', false); + } + $GLOBALS['cfg']['Server']['DisableIS'] = false; + $GLOBALS['cfg']['DBG']['sql'] = false; + $this->assertEquals( + 'utf8_general_ci', + PMA_getDbCollation('pma_test') + ); + + // test case with pma drizzle as true + runkit_constant_redefine('PMA_DRIZZLE', true); + $this->assertEquals( + 'utf8_general_ci_pma_drizzle', + PMA_getDbCollation('pma_test') + ); + + $GLOBALS['cfg']['Server']['DisableIS'] = true; + $GLOBALS['db'] = 'pma_test2'; + $this->assertEquals( + 'bar', + PMA_getDbCollation('pma_test') + ); + $this->assertNotEquals( + 'pma_test', + $GLOBALS['dummy_db'] + ); + } + } + + /** + * Test case for PMA_getCollationDescr() + * + * @param string $collation Collation for which description is reqd + * @param string $desc Expected Description + * + * @return void + * @test + * @dataProvider collationDescr + */ + public function testGetCollationDescr($collation, $desc) + { + $this->assertEquals( + $desc, + PMA_getCollationDescr($collation) + ); + } + + /** + * Data Provider for testPMA_getCollationDescr() + * + * @return array Test data for testPMA_getCollationDescr() + */ + public function collationDescr() + { + return array( + array('binary', 'Binary'), + array('foo_bulgarian_bar', 'Bulgarian'), + array('gb2312_chinese', 'Simplified Chinese'), + array('gbk_chinese', 'Simplified Chinese'), + array('big5_chinese', 'Traditional Chinese'), + array('foo_ci_bar', 'unknown, case-insensitive'), + array('foo_cs_bar', 'unknown, case-sensitive'), + array('foo_croatian_bar', 'Croatian'), + array('foo_czech_bar', 'Czech'), + array('foo_danish_bar', 'Danish'), + array('foo_english_bar', 'English'), + array('foo_esperanto_bar', 'Esperanto'), + array('foo_estonian_bar', 'Estonian'), + array('foo_german1_bar', 'German (dictionary)'), + array('foo_german2_bar', 'German (phone book)'), + array('foo_hungarian_bar', 'Hungarian'), + array('foo_icelandic_bar', 'Icelandic'), + array('foo_japanese_bar', 'Japanese'), + array('foo_latvian_bar', 'Latvian'), + array('foo_lithuanian_bar', 'Lithuanian'), + array('foo_korean_bar', 'Korean'), + array('foo_persian_bar', 'Persian'), + array('foo_polish_bar', 'Polish'), + array('foo_roman_bar', 'West European'), + array('foo_romanian_bar', 'Romanian'), + array('foo_slovak_bar', 'Slovak'), + array('foo_slovenian_bar', 'Slovenian'), + array('foo_spanish_bar', 'Spanish'), + array('foo_spanish2_bar', 'Traditional Spanish'), + array('foo_swedish_bar', 'Swedish'), + array('foo_thai_bar', 'Thai'), + array('foo_turkish_bar', 'Turkish'), + array('foo_ukrainian_bar', 'Ukrainian'), + array('foo_unicode_bar', 'Unicode (multilingual)'), + array('ucs2', 'Unicode (multilingual)'), + array('utf8', 'Unicode (multilingual)'), + array('ascii', 'West European (multilingual)'), + array('cp850', 'West European (multilingual)'), + array('dec8', 'West European (multilingual)'), + array('hp8', 'West European (multilingual)'), + array('latin1', 'West European (multilingual)'), + array('cp1250', 'Central European (multilingual)'), + array('cp852', 'Central European (multilingual)'), + array('latin2', 'Central European (multilingual)'), + array('macce', 'Central European (multilingual)'), + array('cp866', 'Russian'), + array('koi8r', 'Russian'), + array('gb2312', 'Simplified Chinese'), + array('gbk', 'Simplified Chinese'), + array('sjis', 'Japanese'), + array('ujis', 'Japanese'), + array('cp932', 'Japanese'), + array('eucjpms', 'Japanese'), + array('cp1257', 'Baltic (multilingual)'), + array('latin7', 'Baltic (multilingual)'), + array('armscii8', 'Armenian'), + array('armscii', 'Armenian'), + array('big5', 'Traditional Chinese'), + array('cp1251', 'Cyrillic (multilingual)'), + array('cp1256', 'Arabic'), + array('euckr', 'Korean'), + array('hebrew', 'Hebrew'), + array('geostd8', 'Georgian'), + array('greek', 'Greek'), + array('keybcs2', 'Czech-Slovak'), + array('koi8u', 'Ukrainian'), + array('latin5', 'Turkish'), + array('swe7', 'Swedish'), + array('tis620', 'Thai'), + array('foobar', 'unknown'), + array('foo_test_bar', 'unknown'), + array('foo_bin_bar', 'unknown, Binary') + ); + } + + /** + * Test for PMA_generateCharsetDropdownBox + * + * @return void + * @test + */ + public function testGenerateCharsetDropdownBox() + { + $GLOBALS['mysql_charsets'] = array('latin1', 'latin2', 'latin3'); + $GLOBALS['mysql_charsets_available'] = array( + 'latin1' => true, + 'latin2' => false, + 'latin3' => true + ); + $GLOBALS['mysql_charsets_descriptions'] = array( + 'latin1' => 'abc', + 'latin2' => 'def' + ); + $GLOBALS['mysql_collations'] = array( + 'latin1' => array( + 'latin1_german1_ci', + 'latin1_swedish1_ci' + ), + 'latin2' => array('latin1_general_ci'), + 'latin3' => array() + ); + $GLOBALS['mysql_collations_available'] = array( + 'latin1_german1_ci' => true, + 'latin1_swedish1_ci' => false, + 'latin2_general_ci' => true + ); + $result = PMA_generateCharsetDropdownBox(); + + $this->assertContains('name="collation"', $result); + $this->assertNotContains('id="', $result); + $this->assertNotContains('class="autosubmit"', $result); + $this->assertContains('', $result); + $this->assertContains('assertContains('title="latin3', $result); + $this->assertContains('title="abc', $result); + $this->assertNotContains('value="latin1_swedish1_ci"', $result); + $this->assertContains('value="latin1_german1_ci"', $result); + $this->assertNotContains('value="latin2_general1_ci"', $result); + $this->assertContains('title="German', $result); + + $result = PMA_generateCharsetDropdownBox( + 2, null, "test_id", "latin1", false, 0, true, false + ); + $this->assertContains('name="character_set"', $result); + $this->assertNotContains('Charset', $result); + $this->assertContains('class="autosubmit"', $result); + $this->assertContains('id="test_id"', $result); + $this->assertContains('selected="selected">latin1', $result); + } + + /** + * Test for PMA_getServerCollation + * + * @return void + * @test + */ + public function testGetServerCollation() + { + $GLOBALS['cfg']['DBG']['sql'] = false; + $this->assertEquals('utf8_general_ci', PMA_getServerCollation()); + } +} +?>