You are here

function TMGMTEntityTestCaseUtility::createTaxonomyVocab in Translation Management Tool 7

Creates taxonomy vocabulary with custom fields.

To create and attach fields it internally calls TMGMTEntityTestCaseUtility::attachFields(). You can than access these fields calling $this->field_names['node']['YOUR_BUNDLE_NAME'].

Parameters

string $machine_name: Vocabulary machine name.

string $human_name: Vocabulary human readable name.

bool|array $fields_translatable: Flag or definition array to determine which or all fields should be translatable.

Return value

stdClass Created vocabulary object.

3 calls to TMGMTEntityTestCaseUtility::createTaxonomyVocab()
TMGMTEntitySourceLanguageNoneTestCase::setUp in sources/entity/tmgmt_entity.source.none.test
Overrides DrupalWebTestCase::setUp()
TMGMTEntitySourceListTestCase::testTermBundleFilter in sources/entity/ui/tmgmt_entity_ui.list.test
Tests that the term bundle filter works.
TMGMTEntitySourceTestCase::setUp in sources/entity/tmgmt_entity.source.test
Overrides DrupalWebTestCase::setUp()

File

tests/tmgmt.base.entity.test, line 94

Class

TMGMTEntityTestCaseUtility
Utility test case class with helper methods to create entities and their fields with populated translatable content. Extend this class if you create tests in which you need Drupal entities and/or fields.

Code

function createTaxonomyVocab($machine_name, $human_name, $fields_translatable = TRUE) {
  $vocabulary = new stdClass();
  $vocabulary->name = $human_name;
  $vocabulary->machine_name = $machine_name;
  taxonomy_vocabulary_save($vocabulary);
  $this
    ->attachFields('taxonomy_term', $vocabulary->machine_name, $fields_translatable);
  $info = variable_get('entity_translation_taxonomy', array());
  $info[$machine_name] = TRUE;
  variable_set('entity_translation_taxonomy', $info);
  return $vocabulary;
}