Passed
Push — master ( be6e91...b708f5 )
by Joël
03:06 queued 14s
created

TranslationTest::testFrenchLocale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace CodeIgniterGetText\Tests;
3
4
require_once('include/gettext_test_functions.php');
5
require_once('include/gettext_test_constants.php');
6
7
class TranslationTest extends \PHPUnit_Framework_TestCase
8
{
9
    const EXPRESSION = "Let me test this expression";
10
11
    /**
12
     * @before
13
     */
14
    public function testFrenchLocale()
15
    {
16
        $config = array(
17
            'gettext_locale_dir' => 'testTranslations',
18
            'gettext_text_domain' => 'my-domain',
19
            'gettext_catalog_codeset' => 'UTF-8',
20
            'gettext_locale' => 'fr_FR'
21
        );
22
23
        // only for avoid output when launch test
24
        $this->expectOutputRegex('//');
25
26
        \Gettext::init($config);
27
    }
28
29
    public function testDoubleUnderscore()
30
    {
31
        $this->assertEquals("Une expression en Français", __("A expression in English"));
32
    }
33
34
    public function testUnderscroreE()
35
    {
36
        $this->expectOutputRegex("/(Une expression en Français)$/");
37
        _e("A expression in English");
38
    }
39
40
    public function testUnderscroreN_Singular()
41
    {
42
        $this->assertEquals(
43
            "Une expression en Français", __("A expression in English"), 1
44
        );
45
    }
46
47
    public function testUnderscroreN_Plural()
48
    {
49
        $this->assertEquals(
50
            "Une expression en Français", __("A expression in English"), 2
51
        );
52
    }
53
54
}