Passed
Push — master ( 4c0c2c...bf3ff8 )
by Joël
02:21
created

GettextTest::testFileExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
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
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
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