|
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
|
|
|
$state = ($successful ? 'Successful' : 'FAILED'); |
|
17
|
|
|
$regex = '/(info|).*(' . $expression . ').*(' . $state . ')/'; |
|
18
|
|
|
|
|
19
|
|
|
return ( $regex ); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function testCatalogCodeset() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->expectOutputRegex($this->_regex('catalog_codeset')); |
|
25
|
|
|
$this->_library(); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testLocaleDir() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->expectOutputRegex($this->_regex('text domain \(locale dir\)')); |
|
31
|
|
|
$this->_library(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testTextDomain() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->expectOutputRegex($this->_regex('text_domain')); |
|
37
|
|
|
$this->_library(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function testLocale() |
|
41
|
|
|
{ |
|
42
|
|
|
$this->expectOutputRegex($this->_regex('locale')); |
|
43
|
|
|
$this->_library(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testEnvironmentLanguage() |
|
47
|
|
|
{ |
|
48
|
|
|
$this->expectOutputRegex($this->_regex('Environment LANGUAGE')); |
|
49
|
|
|
$this->_library(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
private function _library() |
|
53
|
|
|
{ |
|
54
|
|
|
$config = array(); |
|
55
|
|
|
/* |
|
|
|
|
|
|
56
|
|
|
$config = array( |
|
57
|
|
|
'gettext_locale_dir' => $CI->config->item('gettext_locale_dir'), |
|
58
|
|
|
'gettext_text_domain' => $CI->config->item('gettext_text_domain'), |
|
59
|
|
|
'gettext_catalog_codeset' => $CI->config->item('gettext_catalog_codeset'), |
|
60
|
|
|
'gettext_locale' => $CI->config->item('gettext_locale') |
|
61
|
|
|
); |
|
62
|
|
|
*/ |
|
63
|
|
|
require( realpath(dirname(__FILE__) . '/../') . '/src/config/gettext.php' ); |
|
64
|
|
|
|
|
65
|
|
|
Gettext::init($config); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
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.