HEX
Server: nginx/1.22.0
System: Linux iZuf6jdxbygmf6cco977lcZ 5.10.84-10.4.al8.x86_64 #1 SMP Tue Apr 12 12:31:07 CST 2022 x86_64
User: root (0)
PHP: 7.4.29
Disabled: passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen
Upload Files
File: /data/wwwroot/wordpress/phpMyAdmin/test/libraries/select_lang/locale_gettext_test.php
<?php
/**
 * Tests for working locales
 *
 * @package PhpMyAdmin-test
 */

/*
 * Include to test.
 */

require_once 'libraries/select_lang.lib.php';

/**
 * Class for testing correctness of locales.
 *
 * @package PhpMyAdmin-test
 */
class PMA_Languages_Test extends PHPUnit_Framework_TestCase
{
    /**
     * Test for setting and parsing locales
     *
     * @param string $locale locale name
     *
     * @return void
     *
     * @group large
     * @dataProvider listLocales
     */
    public function testGettext($locale)
    {
        /* We should be able to set the language */
        $this->assertTrue(PMA_langSet($locale));

        /* Bind locales */
        _setlocale(LC_MESSAGES, $GLOBALS['lang']);
        _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
        _textdomain('phpmyadmin');

        /* Grab some texts */
        $this->assertContains('%s', _ngettext('%s table', '%s tables', 10));
        $this->assertContains('%s', _ngettext('%s table', '%s tables', 1));
    }

    /**
     * Data provider to generate list of available locales.
     *
     * @return array with arrays of available locales
     */
    public function listLocales()
    {
        $ret = array();
        foreach ($GLOBALS['available_languages'] as $key => $val) {
            $ret[] = array($key);
        }
        return $ret;
    }
}
?>