diff options
author | Master Yoda <jim_parry@bcit.ca> | 2015-09-20 18:46:40 +0200 |
---|---|---|
committer | Master Yoda <jim_parry@bcit.ca> | 2015-09-20 18:46:40 +0200 |
commit | b6b401bcb134f7e99a9ea18e300c0af44d0685bf (patch) | |
tree | badd5881159e8c1efd7758a641c58aafd6c86f31 /tests | |
parent | 8a9932ba827f5d69e6aaf5f16cb5c3b1c8024904 (diff) |
The Lang unit testing claimed to be testing for non-alpha idioms, but wasn't.
Setup a new test method to isolate this.
Signed-off-by:Master Yoda <jim_parry@bcit.ca>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Lang_test.php | 193 |
1 files changed, 99 insertions, 94 deletions
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 8262d3e75..f8c12d884 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -2,99 +2,104 @@ class Lang_test extends CI_TestCase { - protected $lang; - - public function set_up() - { - $loader_cls = $this->ci_core_class('load'); - $this->ci_instance_var('load', new $loader_cls); - $cls = $this->ci_core_class('lang'); - $this->lang = new $cls; - } - - // -------------------------------------------------------------------- - - public function test_load() - { - // Regular usage - $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $this->assertTrue($this->lang->load('profiler', 'english')); - $this->assertEquals('URI STRING', $this->lang->language['profiler_uri_string']); - - // Already loaded file - $this->assertNull($this->lang->load('profiler', 'english')); - - // Unspecified language (defaults to english) - $this->ci_vfs_clone('system/language/english/date_lang.php'); - $this->assertTrue($this->lang->load('date')); - $this->assertEquals('Year', $this->lang->language['date_year']); - - // A language other than english - $this->ci_vfs_clone('system/language/english/email_lang.php', 'application/language/german/'); - $this->assertTrue($this->lang->load('email', 'german')); - $this->assertEquals('german', $this->lang->is_loaded['email_lang.php']); - - // Non-existent file - $this->setExpectedException( - 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' - ); - $this->lang->load('nonexistent'); - } - - // -------------------------------------------------------------------- - - public function test_non_alpha_idiom() - { - // Non-alpha idiom (should act the same as unspecified language) - // test with existing file - $this->ci_vfs_clone('system/language/english/number_lang.php'); - $this->ci_vfs_clone('system/language/english/number_lang.php', 'system/language/123funny/'); - $this->assertTrue($this->lang->load('number', '123funny')); - $this->assertEquals('Bytes', $this->lang->language['bytes']); - - // test without existing file - $this->ci_vfs_clone('system/language/english/email_lang.php'); - $this->assertTrue($this->lang->load('email', '456funny')); - $this->assertEquals('Bytes', $this->lang->language['bytes']); - } - - // -------------------------------------------------------------------- - - public function test_multiple_file_load() - { - // Multiple files - $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $files = array( - 0 => 'profiler', - 1 => 'nonexistent' - ); - $this->setExpectedException( - 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' - ); - $this->lang->load($files, 'english'); - } - - // -------------------------------------------------------------------- - - public function test_alternative_path_load() - { - // Alternative Path - $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/')); - } - - // -------------------------------------------------------------------- - - /** - * @depends test_load - */ - public function test_line() - { - $this->ci_vfs_clone('system/language/english/profiler_lang.php'); - $this->lang->load('profiler', 'english'); - $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string')); - $this->assertFalse($this->lang->line('nonexistent_string')); - $this->assertFalse($this->lang->line(NULL)); - } + protected $lang; + + public function set_up() + { + $loader_cls = $this->ci_core_class('load'); + $this->ci_instance_var('load', new $loader_cls); + $cls = $this->ci_core_class('lang'); + $this->lang = new $cls; + } + + // -------------------------------------------------------------------- + + public function test_load() + { + // Regular usage + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $this->assertTrue($this->lang->load('profiler', 'english')); + $this->assertEquals('URI STRING', $this->lang->language['profiler_uri_string']); + + // Already loaded file + $this->assertNull($this->lang->load('profiler', 'english')); + + // Unspecified language (defaults to english) + $this->ci_vfs_clone('system/language/english/date_lang.php'); + $this->assertTrue($this->lang->load('date')); + $this->assertEquals('Year', $this->lang->language['date_year']); + + // A language other than english + $this->ci_vfs_clone('system/language/english/email_lang.php', 'system/language/german/'); + $this->assertTrue($this->lang->load('email', 'german')); + $this->assertEquals('german', $this->lang->is_loaded['email_lang.php']); + + // Non-alpha idiom (should act the same as unspecified language) + $this->ci_vfs_clone('system/language/english/number_lang.php'); + $this->assertTrue($this->lang->load('number')); + $this->assertEquals('Bytes', $this->lang->language['bytes']); + + // Non-existent file + $this->setExpectedException( + 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' + ); + $this->lang->load('nonexistent'); + } + + // -------------------------------------------------------------------- + + public function test_non_alpha_idiom() + { + // Non-alpha idiom (should act the same as unspecified language) + // test with existing file + $this->ci_vfs_clone('system/language/english/number_lang.php'); + $this->ci_vfs_clone('system/language/english/number_lang.php', 'system/language/123funny/'); + $this->assertTrue($this->lang->load('number', '123funny')); + $this->assertEquals('Bytes', $this->lang->language['bytes']); + + // test without existing file + $this->ci_vfs_clone('system/language/english/email_lang.php'); + $this->assertTrue($this->lang->load('email', '456funny')); + $this->assertEquals('Bytes', $this->lang->language['bytes']); + } + + // -------------------------------------------------------------------- + + public function test_multiple_file_load() + { + // Multiple files + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $files = array( + 0 => 'profiler', + 1 => 'nonexistent' + ); + $this->setExpectedException( + 'RuntimeException', 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php' + ); + $this->lang->load($files, 'english'); + } + + // -------------------------------------------------------------------- + + public function test_alternative_path_load() + { + // Alternative Path + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/')); + } + + // -------------------------------------------------------------------- + + /** + * @depends test_load + */ + public function test_line() + { + $this->ci_vfs_clone('system/language/english/profiler_lang.php'); + $this->lang->load('profiler', 'english'); + $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string')); + $this->assertFalse($this->lang->line('nonexistent_string')); + $this->assertFalse($this->lang->line(NULL)); + } } |