Completed
Push — feature/high_five ( cf7883...85675c )
by Raúl
05:22
created

ReadPoTest::test_translator_comment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Sepia\Test\UnitTest;
4
5
use Sepia\PoParser\Catalog\Entry;
6
use Sepia\Test\AbstractFixtureTest;
7
8
class ReadPoTest extends AbstractFixtureTest
9
{
10
    public function test_flags()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_flags" is not in camel caps format
Loading history...
11
    {
12
        $catalog = $this->parseFile('multiflags.po');
13
14
        $this->assertCount(1, $catalog->getEntries());
15
        $entry = $catalog->getEntry('Attachment', 'Background Attachment');
16
17
        $this->assertNotNull($entry);
18
        $this->assertCount(2, $entry->getFlags());
19
        $this->assertEquals(array('php-format', 'fuzzy'), $entry->getFlags());
20
    }
21
22
    public function test_translator_comment()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_translator_comment" is not in camel caps format
Loading history...
23
    {
24
        $this->markTestSkipped();
25
    }
26
27
    public function test_developer_comment()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_developer_comment" is not in camel caps format
Loading history...
28
    {
29
        $this->markTestSkipped();
30
    }
31
32
    public function test_entries_with_context()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_entries_with_context" is not in camel caps format
Loading history...
33
    {
34
        $catalog = $this->parseFile('context.po');
35
36
        $withContext = $catalog->getEntry('1', 'start of week');
37
        $withoutContext = $catalog->getEntry('1');
38
39
        $this->assertNotNull($withContext);
40
        $this->assertNotNull($withoutContext);
41
        $this->assertNotEquals($withContext, $withoutContext);
42
    }
43
44
    public function test_previous_untranslated()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_previous_untranslated" is not in camel caps format
Loading history...
45
    {
46
        $catalog = $this->parseFile('previous_unstranslated.po');
47
48
        $this->assertCount(1, $catalog->getEntries());
49
50
        $entry = new Entry('this is a string', 'this is a translation');
51
        $entry->setPreviousEntry(new Entry('this is a previous string', 'this is a previous translation string'));
52
        $this->assertEquals(
53
            $entry,
54
            $catalog->getEntry('this is a string')
55
        );
56
    }
57
58
    public function test_previous_untranslated_multiline()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_previous_untranslated_multiline" is not in camel caps format
Loading history...
59
    {
60
        $this->markTestIncomplete('TODO');
61
        $catalog = $this->parseFile('previous_unstranslated.po');
0 ignored issues
show
Unused Code introduced by
$catalog is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
62
    }
63
64
    public function test_plurals()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_plurals" is not in camel caps format
Loading history...
65
    {
66
        $catalog = $this->parseFile('plurals.po');
67
68
        $entry = $catalog->getEntry('%s post not updated, somebody is editing it.');
69
        $this->assertNotNull($entry);
70
        $this->assertNotEmpty($entry->getMsgStrPlurals());
71
        $this->assertEquals(
72
            array(
73
                '%s entrada no actualizada, alguien la está editando.',
74
                '%s entradas no actualizadas, alguien las está editando.',
75
            ),
76
            $entry->getMsgStrPlurals()
77
        );
78
    }
79
80
    public function test_plurals_multiline()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_plurals_multiline" is not in camel caps format
Loading history...
81
    {
82
        $catalog = $this->parseFile('pluralsMultiline.po');
83
        $entry = $catalog->getEntry('%s post not updated,somebody is editing it.');
84
85
        $this->assertNotNull($entry);
86
        $this->assertNotEmpty($entry->getMsgStrPlurals());
87
        $this->assertEquals(
88
            array(
89
                '%s entrada no actualizada,alguien la está editando.',
90
                '%s entradas no actualizadas,alguien las está editando.',
91
            ),
92
            $entry->getMsgStrPlurals()
93
        );
94
    }
95
96
    public function test_multiline_entries()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_multiline_entries" is not in camel caps format
Loading history...
97
    {
98
        $catalog = $this->parseFile('multilines.po');
99
100
        $longMsgId = '%user% acaba de responder tu comentario.<br>Consulta que te ha dicho %link%aquí</a>.';
101
102
        $entryExpected = new Entry(
103
            $longMsgId,
104
            '%user% acaba de respondre el teu comentari.<br>Consulta que t\'ha dit %link%aquí</a>.'
105
        );
106
        $entryExpected->setReference(
107
            array('../../classes/controller/ccccc.php:361')
108
        );
109
110
        $entry = $catalog->getEntry($longMsgId);
111
        $this->assertNotNull($entry);
112
        $this->assertEquals($entryExpected, $entry);
113
    }
114
115
    public function test_no_header()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_no_header" is not in camel caps format
Loading history...
116
    {
117
        $catalog = $this->parseFile('noheader.po');
118
119
        $this->assertCount(2, $catalog->getEntries());
120
    }
121
122
    public function test_no_blank_lines_separating_entries()
0 ignored issues
show
Coding Style introduced by
Method name "ReadPoTest::test_no_blank_lines_separating_entries" is not in camel caps format
Loading history...
123
    {
124
        $catalog = $this->parseFile('noblankline.po');
125
126
        $this->assertCount(2, $catalog->getEntries());
127
    }
128
}
129