1 | <?php |
||
8 | class PoFeaturesTest extends AbstractFixtureTest |
||
9 | { |
||
10 | public function tearDown() |
||
18 | |||
19 | public function testRead() |
||
20 | { |
||
21 | try { |
||
22 | $parser = Parser::parseFile($this->resourcesPath.'healthy.po'); |
||
23 | $result = $parser->getEntries(); |
||
24 | } catch (\Exception $e) { |
||
25 | $result = array(); |
||
26 | $this->fail($e->getMessage()); |
||
27 | } |
||
28 | |||
29 | $this->assertCount(2, $result); |
||
30 | |||
31 | |||
32 | // Read file without headers. |
||
33 | // It should not skip first entry |
||
34 | try { |
||
35 | $parser = Parser::parseFile($this->resourcesPath.'noheader.po'); |
||
36 | $result = $parser->getEntries(); |
||
37 | } catch (\Exception $e) { |
||
38 | $result = array(); |
||
39 | $this->fail($e->getMessage()); |
||
40 | } |
||
41 | |||
42 | $this->assertCount(2, $result, 'Did not read properly po file without headers.'); |
||
43 | } |
||
44 | |||
45 | |||
46 | /** |
||
47 | * Tests reading the headers. |
||
48 | * |
||
49 | */ |
||
50 | public function testHeaders() |
||
51 | { |
||
52 | try { |
||
53 | $catalog = Parser::parseFile($this->resourcesPath.'healthy.po'); |
||
54 | $headers = $catalog->getHeaders(); |
||
55 | |||
56 | $this->assertCount(18, $headers); |
||
57 | $this->assertEquals("\"Project-Id-Version: \\n\"", $headers[0]); |
||
58 | $this->assertEquals("\"Report-Msgid-Bugs-To: \\n\"", $headers[1]); |
||
59 | $this->assertEquals("\"POT-Creation-Date: 2013-09-25 15:55+0100\\n\"", $headers[2]); |
||
60 | $this->assertEquals("\"PO-Revision-Date: \\n\"", $headers[3]); |
||
61 | $this->assertEquals("\"Last-Translator: Raúl Ferràs <[email protected]>\\n\"", $headers[4]); |
||
62 | $this->assertEquals("\"Language-Team: \\n\"", $headers[5]); |
||
63 | $this->assertEquals("\"MIME-Version: 1.0\\n\"", $headers[6]); |
||
64 | $this->assertEquals("\"Content-Type: text/plain; charset=UTF-8\\n\"", $headers[7]); |
||
65 | $this->assertEquals("\"Content-Transfer-Encoding: 8bit\\n\"", $headers[8]); |
||
66 | $this->assertEquals("\"Plural-Forms: nplurals=2; plural=n != 1;\\n\"", $headers[9]); |
||
67 | $this->assertEquals("\"X-Poedit-SourceCharset: UTF-8\\n\"", $headers[10]); |
||
68 | $this->assertEquals("\"X-Poedit-KeywordsList: __;_e;_n;_t\\n\"", $headers[11]); |
||
69 | $this->assertEquals("\"X-Textdomain-Support: yes\\n\"", $headers[12]); |
||
70 | $this->assertEquals("\"X-Poedit-Basepath: .\\n\"", $headers[13]); |
||
71 | $this->assertEquals("\"X-Generator: Poedit 1.5.7\\n\"", $headers[14]); |
||
72 | $this->assertEquals("\"X-Poedit-SearchPath-0: .\\n\"", $headers[15]); |
||
73 | $this->assertEquals("\"X-Poedit-SearchPath-1: ../..\\n\"", $headers[16]); |
||
74 | $this->assertEquals("\"X-Poedit-SearchPath-2: ../../../modules\\n\"", $headers[17]); |
||
75 | } catch (\Exception $e) { |
||
76 | $this->fail($e->getMessage()); |
||
77 | // $this->assertTrue( false, $e->getMessage() ); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | |||
82 | public function testMultilineId() |
||
83 | { |
||
84 | try { |
||
85 | $catalog = Parser::parseFile($this->resourcesPath.'multilines.po'); |
||
86 | $result = $catalog->getEntries(); |
||
87 | $headers = $catalog->getHeaders(); |
||
88 | |||
89 | $this->assertCount(18, $headers); |
||
90 | $this->assertCount(9, $result); |
||
91 | } catch (\Exception $e) { |
||
92 | $this->fail($e->getMessage()); |
||
93 | } |
||
94 | } |
||
95 | |||
96 | |||
97 | /** |
||
98 | * |
||
99 | * |
||
100 | */ |
||
101 | public function testPlurals() |
||
102 | { |
||
103 | try { |
||
104 | $catalog = Parser::parseFile($this->resourcesPath.'plurals.po'); |
||
105 | $headers = $catalog->getHeaders(); |
||
106 | $result = $catalog->getEntries(); |
||
107 | |||
108 | $this->assertCount(7, $headers); |
||
109 | $this->assertCount(15, $result); |
||
110 | } catch (\Exception $e) { |
||
111 | $this->fail($e->getMessage()); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | public function testPluralsMultiline() |
||
116 | { |
||
117 | try { |
||
118 | $catalog = Parser::parseFile($this->resourcesPath.'pluralsMultiline.po'); |
||
119 | $this->assertCount(2, $catalog->getEntries()); |
||
120 | $entries = $catalog->getEntries(); |
||
121 | foreach ($entries as $id => $entry) { |
||
122 | $this->assertTrue(isset($entry['msgstr[0]'])); |
||
123 | $this->assertTrue(isset($entry['msgstr[1]'])); |
||
124 | } |
||
125 | } catch (\Exception $e) { |
||
126 | $this->fail($e->getMessage()); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | |||
131 | /** |
||
132 | * Test Writing file |
||
133 | */ |
||
134 | public function testWrite() |
||
135 | { |
||
136 | $this->markTestSkipped(); |
||
137 | // Read & write a simple file |
||
138 | $catalog = Parser::parseFile($this->resourcesPath.'healthy.po'); |
||
139 | $catalog->writeFile($this->resourcesPath.'temp.po'); |
||
|
|||
140 | |||
141 | $this->assertFileEquals($this->resourcesPath.'healthy.po', $this->resourcesPath.'temp.po'); |
||
142 | |||
143 | // Read & write a file with no headers |
||
144 | $catalog = Parser::parseFile($this->resourcesPath.'noheader.po'); |
||
145 | $catalog->writeFile($this->resourcesPath.'temp.po'); |
||
146 | |||
147 | $this->assertFileEquals($this->resourcesPath.'noheader.po', $this->resourcesPath.'temp.po'); |
||
148 | |||
149 | // Read & write a po file with multilines |
||
150 | $catalog = Parser::parseFile($this->resourcesPath.'multilines.po'); |
||
151 | $catalog->writeFile($this->resourcesPath.'temp.po'); |
||
152 | |||
153 | $this->assertFileEquals($this->resourcesPath.'multilines.po', $this->resourcesPath.'temp.po'); |
||
154 | |||
155 | // Read & write a po file with contexts |
||
156 | $catalog = Parser::parseFile($this->resourcesPath.'context.po'); |
||
157 | $catalog->writeFile($this->resourcesPath.'temp.po'); |
||
158 | |||
159 | $this->assertFileEquals($this->resourcesPath.'context.po', $this->resourcesPath.'temp.po'); |
||
160 | |||
161 | |||
162 | // Read & write a po file with previous unstranslated strings |
||
163 | $catalog = Parser::parseFile($this->resourcesPath.'previous_unstranslated.po'); |
||
164 | $catalog->writeFile($this->resourcesPath.'temp.po'); |
||
165 | |||
166 | $this->assertFileEquals($this->resourcesPath.'previous_unstranslated.po', $this->resourcesPath.'temp.po'); |
||
167 | |||
168 | // Read & write a po file with multiple flags |
||
169 | $catalog = Parser::parseFile($this->resourcesPath.'multiflags.po'); |
||
170 | $catalog->writeFile($this->resourcesPath.'temp.po'); |
||
171 | |||
172 | $this->assertFileEquals($this->resourcesPath.'multiflags.po', $this->resourcesPath.'temp.po'); |
||
173 | |||
174 | |||
175 | unlink($this->resourcesPath.'temp.po'); |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * Test update entry, update plural forms |
||
180 | */ |
||
181 | public function testUpdatePlurals() |
||
182 | { |
||
183 | $this->markTestSkipped(); |
||
184 | $msgid = '%s post not updated, somebody is editing it.'; |
||
185 | $msgstr = array( |
||
186 | "%s entrada no actualizada, alguien la está editando...", |
||
187 | "%s entradas no actualizadas, alguien las está editando...", |
||
188 | ); |
||
189 | |||
190 | $parser = Parser::parseFile($this->resourcesPath.'plurals.po'); |
||
191 | |||
192 | $parser->setEntry( |
||
193 | $msgid, |
||
194 | array( |
||
195 | 'msgid' => $msgid, |
||
196 | 'msgstr' => $msgstr, |
||
197 | ) |
||
198 | ); |
||
199 | |||
200 | $parser->writeFile($this->resourcesPath.'temp.po'); |
||
201 | |||
202 | $parser = Parser::parseFile($this->resourcesPath.'temp.po'); |
||
203 | $newPlurals = $parser->getEntries(); |
||
204 | $this->assertEquals($newPlurals[$msgid]['msgstr'], $msgstr); |
||
205 | } |
||
206 | |||
207 | |||
208 | /** |
||
209 | * Test update with fuzzy flag. |
||
210 | * |
||
211 | * @todo |
||
212 | */ |
||
213 | public function testUpdateWithFuzzy() |
||
224 | |||
225 | /** |
||
226 | * Test for success update headers |
||
227 | */ |
||
228 | public function testUpdateHeaders() |
||
229 | { |
||
230 | $this->markTestSkipped(); |
||
231 | $parser = Parser::parseFile($this->resourcesPath.'context.po'); |
||
254 | |||
255 | /** |
||
256 | * Test for fail update headers |
||
257 | */ |
||
258 | public function testUpdateHeadersWrong() |
||
265 | |||
266 | /** |
||
267 | * Test for po files with no blank lines between entries |
||
268 | */ |
||
269 | public function testNoBlankLines() |
||
287 | |||
288 | |||
289 | /** |
||
290 | * Test for entries with multiple flags |
||
291 | */ |
||
292 | public function testFlags() |
||
308 | |||
309 | |||
310 | /** |
||
311 | * Test for reading previous unstranslated strings |
||
312 | */ |
||
313 | public function testPreviousUnstranslated() |
||
331 | } |
||
332 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.