You are here

function BlogAPIModuleTestCase::add_vocabulary in SimpleTest 6

Add taxonomy vocabulary.

Parameters

string $vocab Vocabulary name.:

1 call to BlogAPIModuleTestCase::add_vocabulary()
BlogAPIModuleTestCase::test_blog_API in tests/blogapi_module.test

File

tests/blogapi_module.test, line 120

Class

BlogAPIModuleTestCase

Code

function add_vocabulary($vocab) {
  $edit = array();
  $edit['name'] = $vocab;
  $edit['nodes[blog]'] = TRUE;
  $this
    ->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, 'Save');
  $this
    ->assertWantedRaw(t('Created new vocabulary %vocab.', array(
    '%vocab' => $edit['name'],
  )), 'Taxonomy vocabulary added.');
  $vocab_arr = taxonomy_get_vocabularies();
  $vid = NULL;
  foreach ($vocab_arr as $vocab_item) {
    if ($vocab_item->name == $vocab) {
      $vid = $vocab_item->vid;
      break;
    }
  }
  $this
    ->assertNotNull($vid, 'Vocabulary found in database.');
  return $vid;
}