Skip to content

Commit 3347517

Browse files
committed
#282 Added test for the previous translation
1 parent 7981363 commit 3347517

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

tests/StrictPoLoaderTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ public function testCollapsedSyntax(): void
3535
$this->assertEquals($translations->find('ctx', 'original')->getComments()->toArray()[0], ' comment');
3636
}
3737

38+
public function testPreviousTranslation(): void
39+
{
40+
$po = '#| msgctxt "previous ctx"
41+
#| msgid "previous original"
42+
#| msgid_plural "previous plural"
43+
msgctxt "ctx"
44+
msgid "original"
45+
msgid_plural "plural"
46+
msgstr "translation"';
47+
$translations = $this->createPoLoader()->loadString($po);
48+
49+
$translation = $translations->find('ctx', 'original');
50+
$this->assertNotNull($translation);
51+
$this->assertEquals($translation->getContext(), 'ctx');
52+
$this->assertEquals($translation->getOriginal(), 'original');
53+
$this->assertEquals($translation->getPlural(), 'plural');
54+
$this->assertEquals($translation->getTranslation(), 'translation');
55+
56+
$this->assertEquals($translation->getPreviousContext(), 'previous ctx');
57+
$this->assertEquals($translation->getPreviousOriginal(), 'previous original');
58+
$this->assertEquals($translation->getPreviousPlural(), 'previous plural');
59+
60+
}
61+
3862
public function badFormattedPoProvider(): array
3963
{
4064
return [

0 commit comments

Comments
 (0)