<commit_before><?php

require_once("class.l10n.inc.php");
require_once("conf.l10n.inc.php");

/**
 * This tests Lunr's L10n class
 * @covers L10n
 */
class L10nTest extends PHPUnit_Framework_TestCase
{

    /**
     * Test the static function get_supported_languages()
     * @covers L10n::get_supported_languages
     */
    public function testGetSupportedLanguages()
    {
        global $config;
        $languages = array();
        if ($handle = opendir($config['l10n']['locales']))
        {
            while (FALSE !== ($file = readdir($handle)))
            {
                if ($file != "." && $file != ".." && $file != ".gitignore")
                {
                    $languages[] = $file;
                }
            }
        }
        closedir($handle);
        $languages[] = $config['l10n']['default_language'];
        $this->assertEquals(L10n::get_supported_languages(), $languages);
        return $languages;
    }

}

?><commit_msg>tests: Implement remaining unit tests for L10n class<commit_after><?php

require_once("class.l10n.inc.php");
require_once("conf.l10n.inc.php");

/**
 * This tests Lunr's L10n class
 * @covers L10n
 */
class L10nTest extends PHPUnit_Framework_TestCase
{

    protected $languages;

    protected function setUp()
    {
        global $config;
        $this->languages = array();
        if ($handle = opendir($config['l10n']['locales']))
        {
            while (FALSE !== ($file = readdir($handle)))
            {
                if ($file != "." && $file != ".." && $file != ".gitignore")
                {
                    $this->languages[] = $file;
                }
            }
        }
        closedir($handle);
        $this->languages[] = $config['l10n']['default_language'];
    }

    /**
     * Test the static function get_supported_languages()
     * @covers L10n::get_supported_languages
     */
    public function testGetSupportedLanguages()
    {
        $this->assertEquals($this->languages, L10n::get_supported_languages());
    }

    /**
     * Test the static function set_language()
     * @depends M2DateTimeTest::testDelayedTimestamp
     * @depends testGetSupportedLanguages
     * @dataProvider languageProvider
     * @covers L10n::set_language
     */
    public function testSetLanguage($locale, $language)
    {
        if (in_array($locale, $this->languages))
        {
            $this->assertEquals($locale, L10n::set_language($language));
        }
        else
        {
            global $config;
            $this->assertEquals($config['l10n']['default_language'], L10n::set_language($language));
        }
    }

    public function languageProvider()
    {
        return array(array("en_GB", "en"), array("nl_NL", "nl"), array("de_DE", "de"));
    }
}

?>
{'fraction_non_alphanumeric': 0.15348501263994221, 'fraction_numerical': 0.016973636691946552, 'mean_word_length': 2.239766081871345, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7313125', 'n_tokens_mistral': 862, 'n_tokens_neox': 817, 'n_words': 145}