Prepended constants with C_ to avoid reserved words as per https://www.php.net/manual...
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / LanguageFactoryTest.php
blobe1a73ac7929db3a3c21499977f02c15072373350
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()
13 $this->factory = HTMLPurifier_LanguageFactory::instance();
14 parent::setUp();
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');
25 // lazy loading test
26 $this->assertIdentical(count($language->messages), 0);
27 $language->load();
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');
40 $language->load();
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');
56 $language->load();
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);
73 // vim: et sw=4 sts=4