Aleksander Machniak
2016-02-05 bd0551b22076b82a6d49e9f7a2b2e0c90a1b2326
tests/Framework/Charset.php
@@ -4,6 +4,8 @@
 * Test class to test rcube_charset class
 *
 * @package Tests
 * @group iconv
 * @group mbstring
 */
class Framework_Charset extends PHPUnit_Framework_TestCase
{
@@ -15,7 +17,8 @@
    {
        return array(
            array('', ''),
            array("\xC1", ''),
            array("\xC1", ""),
            array("Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν", "Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν"),
        );
    }
@@ -25,6 +28,16 @@
    function test_clean($input, $output)
    {
        $this->assertEquals($output, rcube_charset::clean($input));
    }
    /**
     * Just check for faulty byte-sequence, regardless of the actual cleaning results
     */
    function test_clean_2()
    {
        $bogus = "сим\xD0вол";
        $this->assertRegExp('/\xD0\xD0/', $bogus);
        $this->assertNotRegExp('/\xD0\xD0/', rcube_charset::clean($bogus));
    }
    /**
@@ -159,4 +172,22 @@
        $this->assertEquals($output, rcube_charset::detect($input, $fallback));
    }
    /**
     * Data for test_detect()
     */
    function data_detect_with_lang()
    {
        return array(
            array('Åã¥Ü¦WºÙ,¥D­n', 'zh_TW', 'BIG-5'),
        );
    }
    /**
     * @dataProvider data_detect_with_lang
     */
    function test_detect_with_lang($input, $lang, $output)
    {
        $this->assertEquals($output, rcube_charset::detect($input, $output, $lang));
    }
}