You are here

function ServicesResourceTaxonomyTests::createVocabulary in Services 7.3

Same name and namespace in other branches
  1. 6.3 tests/functional/ServicesResourceTaxonomyTests.test \ServicesResourceTaxonomyTests::createVocabulary()

Helper. Create taxonomy vocabulary.

13 calls to ServicesResourceTaxonomyTests::createVocabulary()
ServicesResourceTaxonomyTests::testTaxonomyTermIndex in tests/functional/ServicesResourceTaxonomyTests.test
ServicesResourceTaxonomyTests::testTaxonomyVocabularyIndex in tests/functional/ServicesResourceTaxonomyTests.test
ServicesResourceTaxonomyTests::testTermCreate in tests/functional/ServicesResourceTaxonomyTests.test
Test taxonomy term create method.
ServicesResourceTaxonomyTests::testTermCreateLegacy in tests/functional/ServicesResourceTaxonomyTests.test
Test taxonomy term create method (Legacy).
ServicesResourceTaxonomyTests::testTermDelete in tests/functional/ServicesResourceTaxonomyTests.test
Test taxonomy term delete method.

... See full list

File

tests/functional/ServicesResourceTaxonomyTests.test, line 625
Call the endpoint tests when no authentication is being used.

Class

ServicesResourceTaxonomyTests
Taxonomy resource test class.

Code

function createVocabulary() {
  $vocabulary = (object) array(
    'name' => $this
      ->randomName(),
    'machine_name' => $this
      ->randomName(),
    'description' => $this
      ->randomString(),
    'hierarchy' => 1,
    'module' => 'services',
    'weight' => 0,
  );
  taxonomy_vocabulary_save($vocabulary);
  $query = db_select('taxonomy_vocabulary', 'v')
    ->fields('v', array(
    'vid',
  ))
    ->condition('v.name', $vocabulary->name);
  $vid = $query
    ->execute()
    ->fetchField();
  return (array) taxonomy_vocabulary_load($vid);
}