3 class HTMLPurifier_LanguageFactoryTest
extends HTMLPurifier_Harness
7 * Protected reference of global factory we're testing.
11 public function setUp()
13 $this->factory
= HTMLPurifier_LanguageFactory
::instance();
17 public function test()
19 $this->config
->set('Core.Language', 'en');
20 $language = $this->factory
->create($this->config
, $this->context
);
22 $this->assertIsA($language, 'HTMLPurifier_Language');
23 $this->assertIdentical($language->code
, 'en');
26 $this->assertIdentical(count($language->messages
), 0);
28 $this->assertNotEqual(count($language->messages
), 0);
32 public function testFallback()
34 $this->config
->set('Core.Language', 'en-x-test');
35 $language = $this->factory
->create($this->config
, $this->context
);
37 $this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
38 $this->assertIdentical($language->code
, 'en-x-test');
42 // test overloaded message
43 $this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier X');
45 // test inherited message
46 $this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza');
50 public function testFallbackWithNoClass()
52 $this->config
->set('Core.Language', 'en-x-testmini');
53 $language = $this->factory
->create($this->config
, $this->context
);
54 $this->assertIsA($language, 'HTMLPurifier_Language');
55 $this->assertIdentical($language->code
, 'en-x-testmini');
57 $this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier XNone');
58 $this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza');
59 $this->assertIdentical($language->error
, false);
62 public function testNoSuchLanguage()
64 $this->config
->set('Core.Language', 'en-x-testnone');
65 $language = $this->factory
->create($this->config
, $this->context
);
66 $this->assertIsA($language, 'HTMLPurifier_Language');
67 $this->assertIdentical($language->code
, 'en-x-testnone');
68 $this->assertIdentical($language->error
, true);