2007-01-29 20:11:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once 'HTMLPurifier/LanguageFactory.php';
|
|
|
|
|
|
|
|
class HTMLPurifier_LanguageFactoryTest extends UnitTestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
|
|
|
|
$factory = HTMLPurifier_LanguageFactory::instance();
|
|
|
|
|
2007-06-26 19:33:37 +00:00
|
|
|
$config = HTMLPurifier_Config::create(array('Core.Language' => 'en'));
|
|
|
|
$context = new HTMLPurifier_Context();
|
|
|
|
$language = $factory->create($config, $context);
|
2007-01-29 20:11:00 +00:00
|
|
|
|
|
|
|
$this->assertIsA($language, 'HTMLPurifier_Language');
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($language->code, 'en');
|
2007-01-29 20:11:00 +00:00
|
|
|
|
|
|
|
// lazy loading test
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical(count($language->messages), 0);
|
2007-01-29 20:11:00 +00:00
|
|
|
$language->load();
|
|
|
|
$this->assertNotEqual(count($language->messages), 0);
|
|
|
|
|
|
|
|
// actual tests for content can be found in LanguageTest
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testFallback() {
|
|
|
|
|
|
|
|
$factory = HTMLPurifier_LanguageFactory::instance();
|
|
|
|
|
2007-06-26 19:33:37 +00:00
|
|
|
$config = HTMLPurifier_Config::create(array('Core.Language' => 'en-x-test'));
|
|
|
|
$context = new HTMLPurifier_Context();
|
|
|
|
|
|
|
|
$language = $factory->create($config, $context);
|
2007-01-29 20:11:00 +00:00
|
|
|
|
|
|
|
$this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
|
2007-05-05 20:17:04 +00:00
|
|
|
$this->assertIdentical($language->code, 'en-x-test');
|
2007-01-29 20:11:00 +00:00
|
|
|
|
|
|
|
$language->load();
|
|
|
|
|
|
|
|
// test overloaded message
|
2007-06-25 01:11:56 +00:00
|
|
|
$this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier X');
|
2007-01-29 20:11:00 +00:00
|
|
|
|
|
|
|
// test inherited message
|
2007-06-25 01:11:56 +00:00
|
|
|
$this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza');
|
2007-01-29 20:11:00 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|