@@ -548,25 +548,38 @@ public function testVueJs2MultipleDomainScanning()
548548 }
549549 }
550550
551- public function testXliff ()
551+ public function testXliffUnitIds ()
552552 {
553- $ translations = static ::get ('xliff/Xliff ' , 'Xliff ' );
554- $ countTranslations = 2 ;
555- $ countTranslated = 2 ;
553+ $ translations = static ::get ('xliff/Xliff ' , 'Xliff ' , [ ' unitid_as_id ' => true ] );
554+ $ countTranslations = 3 ;
555+ $ countTranslated = 3 ;
556556 $ countHeaders = 9 ;
557557
558558 $ this ->assertCount ($ countTranslations , $ translations );
559559 $ this ->assertCount ($ countHeaders , $ translations ->getHeaders ());
560- $ this ->assertEquals (2 , $ translations ->countTranslated ());
561-
562- $ translation1 = $ translations ->find (null , 'one file ' );
563- $ this ->assertEquals (\Gettext \Generators \Xliff::getUnitID ($ translation1 ), 'custom.unit.id ' );
564-
565- $ translation2 = $ translations ->find (null , 'one ' );
566- $ this ->assertEquals (\Gettext \Generators \Xliff::getUnitID ($ translation2 ), 'second.custom.unit.id ' );
560+ $ this ->assertEquals ($ countTranslated , $ translations ->countTranslated ());
567561
568- $ this ->assertContent ($ translations , 'xliff/Po ' );
562+ foreach ($ translations as $ translation ) {
563+ switch (\Gettext \Generators \Xliff::getUnitID ($ translation )) {
564+ case 'custom.unit.id ' :
565+ $ this ->assertEquals ($ translation ->getOriginal (), 'one file ' );
566+ $ this ->assertEquals ($ translation ->getTranslation (), '1 plik ' );
567+ break ;
568+ case 'second.custom.unit.id ' :
569+ $ this ->assertEquals ($ translation ->getOriginal (), 'one ' );
570+ $ this ->assertEquals ($ translation ->getTranslation (), '1 ' );
571+ break ;
572+ case 'duplicate.source.unit.id ' :
573+ $ this ->assertEquals ($ translation ->getOriginal (), 'one ' );
574+ $ this ->assertEquals ($ translation ->getTranslation (), 'uno ' );
575+ break ;
576+ default :
577+ $ this ->assertFalse (true );
578+ }
579+ }
569580
570- $ this ->runTestFormat ('xliff/Po ' , $ countTranslations , $ countTranslated , $ countHeaders );
581+ // Converting from an XLIFF that contains duplicate <source> elements
582+ // to a PO file will result in the loss of the duplicates.
583+ $ this ->runTestFormat ('xliff/Po ' , $ countTranslations -1 , $ countTranslated -1 , $ countHeaders );
571584 }
572585}
0 commit comments