1 | <?php |
||
9 | class WriteTest extends AbstractFixtureTest |
||
10 | { |
||
11 | public function testWrite() |
||
12 | { |
||
13 | $faker = \Faker\Factory::create(); |
||
14 | $catalogSource = new Catalog(); |
||
15 | |||
16 | // Normal Entry |
||
17 | $entry = Catalog\EntryFactory::createFromArray(array( |
||
18 | 'msgid' => 'string.1', |
||
19 | 'msgstr' => 'translation.1', |
||
20 | 'msgctxt' => 'context.1', |
||
21 | 'reference' => array('src/views/forms.php:44'), |
||
22 | 'tcomment' => array('translator comment'), |
||
23 | 'ccomment' => array('code comment'), |
||
24 | 'flags' => array('1', '2', '3') |
||
25 | )); |
||
26 | $previousEntry = Catalog\EntryFactory::createFromArray(array( |
||
27 | 'msgid' => 'previous.string.1', |
||
28 | 'msgctxt' => 'previous.context.1' |
||
29 | )); |
||
30 | $entry->setPreviousEntry($previousEntry); |
||
31 | $catalogSource->addEntry($entry); |
||
32 | |||
33 | // Obsolete entry |
||
34 | $entry = Catalog\EntryFactory::createFromArray(array( |
||
35 | 'msgid' => 'obsolete.1', |
||
36 | 'msgstr' => $faker->paragraph(5), |
||
37 | 'msgctxt' => 'obsolete.context', |
||
38 | 'obsolete' => true |
||
39 | )); |
||
40 | $catalogSource->addEntry($entry); |
||
41 | |||
42 | |||
43 | $this->saveCatalog($catalogSource); |
||
44 | |||
45 | $catalog = $this->parseFile('temp.po'); |
||
46 | $this->assertPoFile($catalogSource, $catalog); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @throws \Exception |
||
51 | */ |
||
52 | protected function saveCatalog(Catalog $catalog) |
||
61 | |||
62 | private function assertPoFile(Catalog $catalogSource, Catalog $catalogNew) |
||
85 | |||
86 | public function tearDown() |
||
94 | } |
||
95 |