3 class HTMLPurifier_LanguageFactoryTest
extends HTMLPurifier_Harness
7 * Protected reference of global factory we're testing.
11 public function setUp() {
12 $this->factory
= HTMLPurifier_LanguageFactory
::instance();
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');
25 $this->assertIdentical(count($language->messages
), 0);
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');
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');
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);