You are here

function BlogAPIModuleTestCase::add_term in SimpleTest 6

Add a taxonomy term to vocabulary.

Parameters

integer $vid Vocabulary id.:

string $term Term name.:

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

File

tests/blogapi_module.test, line 146

Class

BlogAPIModuleTestCase

Code

function add_term($vid, $term) {
  $edit = array();
  $edit['name'] = $term;
  $this
    ->drupalPost('admin/content/taxonomy/' . $vid . '/add/term', $edit, 'Save');
  $this
    ->assertWantedRaw(t('Created new term %term.', array(
    '%term' => $edit['name'],
  )), 'Taxonomy term added.');
  $tree = taxonomy_get_tree($vid);
  $tid = NULL;
  foreach ($tree as $tree_term) {
    if ($tree_term->name == $term) {
      $tid = $tree_term->tid;
      break;
    }
  }
  $this
    ->assertNotNull($tid, 'Term found in database.');
  return $tid;
}