0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 23:28:42 +00:00
htmlpurifier/tests/HTMLPurifier/LanguageFactoryTest.php
Edward Z. Yang 00ea2062d4 [3.1.0] Fix buggy LanguageFactory. This revision is incomplete.
- Some bogus commits to Generator were made, and will be reverted next revision.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1722 48356398-32a2-884e-a903-53898d9a118a
2008-05-15 17:47:47 +00:00

56 lines
1.8 KiB
PHP

<?php
class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
{
function test() {
$factory = HTMLPurifier_LanguageFactory::instance();
$config = HTMLPurifier_Config::create(array('Core.Language' => 'en'));
$context = new HTMLPurifier_Context();
$language = $factory->create($config, $context);
$this->assertIsA($language, 'HTMLPurifier_Language');
$this->assertIdentical($language->code, 'en');
// lazy loading test
$this->assertIdentical(count($language->messages), 0);
$language->load();
$this->assertNotEqual(count($language->messages), 0);
// actual tests for content can be found in LanguageTest
}
function testFallback() {
$factory = HTMLPurifier_LanguageFactory::instance();
$config = HTMLPurifier_Config::create(array('Core.Language' => 'en-x-test'));
$context = new HTMLPurifier_Context();
$language = $factory->create($config, $context);
$this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
$this->assertIdentical($language->code, 'en-x-test');
$language->load();
// test overloaded message
$this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier X');
// test inherited message
$this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza');
}
function testFullFallback() {
$factory = HTMLPurifier_LanguageFactory::instance();
$this->config->set('Core', 'Language', 'en-x-none');
$language = $factory->create($this->config, $this->context);
}
}