You are here

function i18n_Taxonomy_Test::testTaxonomyTranslationAPI in Internationalization 6

File

tests/i18n_taxonomy.test, line 26

Class

i18n_Taxonomy_Test

Code

function testTaxonomyTranslationAPI() {

  // Create a vocabulary with some terms
  $number = 4;
  $vocab = $this
    ->drupalCreateVocabulary(array(
    'i18nmode' => I18N_TAXONOMY_LOCALIZE,
  ));
  $this
    ->assertEqual(i18ntaxonomy_vocabulary($vocab - vid), I18N_TAXONOMY_LOCALIZE, 'A vocabulary has been created and it is localizable.');
  $terms = $this
    ->drupalCreateTerms($number, array(
    'vid' => $vocab->vid,
  ));
  $this
    ->assertEqual(count($terms), $number, "Four translatable terms have been created.");

  // Create and Save Spanish translation for all of them
  $count = 0;
  $lang = 'es';
  foreach ($terms as $term) {
    $translations[$term->tid] = $this
      ->randomName(10);

    // Save Spanish translation
    $translations[$term->tid] = $this
      ->i18nstringsCreateTranslation("taxonomy:term:{$term->tid}:name", $lang);
  }
}