diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test index 42a0fbd..465d741 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -617,6 +617,15 @@ class LocalePluralFormatTest extends DrupalWebTestCase { 'langcode' => 'hr', )); + // Attempt to import some broken .po files as well to prove that these + // will not overwrite the proper plural formula imported above. + $this->importPoFile($this->getPoFileWithMissingPlural(), array( + 'langcode' => 'fr', + )); + $this->importPoFile($this->getPoFileWithBrokenPlural(), array( + 'langcode' => 'hr', + )); + // Reset static caches from locale_get_plural() to ensure we get fresh data. drupal_static_reset('locale_get_plural'); drupal_static_reset('locale_get_plural:plurals'); @@ -656,6 +665,7 @@ class LocalePluralFormatTest extends DrupalWebTestCase { $name = tempnam('temporary://', "po_") . '.po'; file_put_contents($name, $contents); $options['files[file]'] = $name; + $options['mode'] = LOCALE_IMPORT_OVERWRITE; $this->drupalPost('admin/config/regional/translate/import', $options, t('Import')); drupal_unlink($name); } @@ -706,6 +716,41 @@ msgid "Monday" msgstr "Ponedjeljak" EOF; } + + /** + * Returns a .po file with a missing plural formula. + */ + function getPoFileWithMissingPlural() { + return <<< EOF +msgid "" +msgstr "" +"Project-Id-Version: Drupal 7\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=UTF-8\\n" +"Content-Transfer-Encoding: 8bit\\n" + +msgid "Monday" +msgstr "lundi" +EOF; + } + + /** + * Returns a .po file with a broken plural formula. + */ + function getPoFileWithBrokenPlural() { + return <<< EOF +msgid "" +msgstr "" +"Project-Id-Version: Drupal 7\\n" +"MIME-Version: 1.0\\n" +"Content-Type: text/plain; charset=UTF-8\\n" +"Content-Transfer-Encoding: 8bit\\n" +"Plural-Forms: broken, will not parse\\n" + +msgid "Monday" +msgstr "Ponedjeljak" +EOF; + } } /**