1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// Simulate constants defined in CodeIgniter |
4
|
|
|
define('APPPATH', dirname(__FILE__)); |
5
|
|
|
|
6
|
|
|
// Simulate helper |
7
|
|
|
function log_message($level, $message) { |
8
|
|
|
echo "\n\r" . $level . '|' . $message; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
class GettextTest extends PHPUnit_Framework_TestCase |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
private function _regex($expression, $successful = TRUE) |
15
|
|
|
{ |
16
|
|
|
$log = ($successful ? 'info' : 'debug'); |
17
|
|
|
$regex = '/(' . $log . '|).*(' . $expression . ')/'; |
18
|
|
|
|
19
|
|
|
return ($regex); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testCatalogCodeset() |
23
|
|
|
{ |
24
|
|
|
$this->expectOutputRegex($this->_regex('bind text domain code set')); |
25
|
|
|
$this->_library(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testLocaleDir() |
29
|
|
|
{ |
30
|
|
|
$this->expectOutputRegex($this->_regex('bind text domain directory')); |
31
|
|
|
$this->_library(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testTextDomain() |
35
|
|
|
{ |
36
|
|
|
$this->expectOutputRegex($this->_regex('set text domain')); |
37
|
|
|
$this->_library(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testLocale() |
41
|
|
|
{ |
42
|
|
|
$this->expectOutputRegex($this->_regex('set locale')); |
43
|
|
|
$this->_library(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testEnvironmentLanguage() |
47
|
|
|
{ |
48
|
|
|
$this->expectOutputRegex($this->_regex('set environment language')); |
49
|
|
|
$this->_library(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testFileExists() |
53
|
|
|
{ |
54
|
|
|
$this->expectOutputRegex($this->_regex('check MO file exists')); |
55
|
|
|
$this->_library(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
private function _library() |
59
|
|
|
{ |
60
|
|
|
$config = array(); |
61
|
|
|
/* |
|
|
|
|
62
|
|
|
$config = array( |
63
|
|
|
'gettext_locale_dir' => $CI->config->item('gettext_locale_dir'), |
64
|
|
|
'gettext_text_domain' => $CI->config->item('gettext_text_domain'), |
65
|
|
|
'gettext_catalog_codeset' => $CI->config->item('gettext_catalog_codeset'), |
66
|
|
|
'gettext_locale' => $CI->config->item('gettext_locale') |
67
|
|
|
); |
68
|
|
|
*/ |
69
|
|
|
|
70
|
|
|
// Load default config array |
71
|
|
|
require(realpath(dirname(__FILE__) . '/../') . '/src/config/gettext.php'); |
72
|
|
|
|
73
|
|
|
Gettext::init($config); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.