Fix two minor bugs, updating Phorum and removing unused $dir variable.
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / LanguageFactoryTest.php
blob9fea24f42df0daaf626b0172a2adcb86aaf6c090
1 <?php
3 class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
6 /**
7 * Protected reference of global factory we're testing.
8 */
9 protected $factory;
11 public function setUp() {
12 $this->factory = HTMLPurifier_LanguageFactory::instance();
13 parent::setUp();
16 function test() {
18 $this->config->set('Core.Language', 'en');
19 $language = $this->factory->create($this->config, $this->context);
21 $this->assertIsA($language, 'HTMLPurifier_Language');
22 $this->assertIdentical($language->code, 'en');
24 // lazy loading test
25 $this->assertIdentical(count($language->messages), 0);
26 $language->load();
27 $this->assertNotEqual(count($language->messages), 0);
31 function testFallback() {
33 $this->config->set('Core.Language', 'en-x-test');
34 $language = $this->factory->create($this->config, $this->context);
36 $this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
37 $this->assertIdentical($language->code, 'en-x-test');
39 $language->load();
41 // test overloaded message
42 $this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier X');
44 // test inherited message
45 $this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza');
49 function testFallbackWithNoClass() {
50 $this->config->set('Core.Language', 'en-x-testmini');
51 $language = $this->factory->create($this->config, $this->context);
52 $this->assertIsA($language, 'HTMLPurifier_Language');
53 $this->assertIdentical($language->code, 'en-x-testmini');
54 $language->load();
55 $this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier XNone');
56 $this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza');
57 $this->assertIdentical($language->error, false);
60 function testNoSuchLanguage() {
61 $this->config->set('Core.Language', 'en-x-testnone');
62 $language = $this->factory->create($this->config, $this->context);
63 $this->assertIsA($language, 'HTMLPurifier_Language');
64 $this->assertIdentical($language->code, 'en-x-testnone');
65 $this->assertIdentical($language->error, true);
70 // vim: et sw=4 sts=4