Test Setup Failed
Push — master ( cf92d1...ffbff4 )
by Joël
02:52
created

GettextTest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2

7 Methods

Rating   Name   Duplication   Size   Complexity  
A _regex() 0 7 2
A testCatalogCodeset() 0 5 1
A testLocaleDir() 0 5 1
A testTextDomain() 0 5 1
A testLocale() 0 5 1
A testEnvironmentLanguage() 0 5 1
A _library() 0 15 1
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
        $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
        /*
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...
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