blob: 87a71c88506f8a3e345c4ef956b5bdfb890c13b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
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', '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');
}
// --------------------------------------------------------------------
/**
* @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));
}
}
|