You are here

function ServicesResourceTaxonomyTests::testVocabularyCreate in Services 7.3

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

Test taxonomy vocabulary create method.

File

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

Class

ServicesResourceTaxonomyTests
Taxonomy resource test class.

Code

function testVocabularyCreate() {
  $path = $this->endpoint->path;
  $vocabulary = array(
    'name' => $this
      ->randomName(),
    'machine_name' => $this
      ->randomName(),
    'description' => $this
      ->randomString(),
    'hierarchy' => 1,
    'module' => 'services',
    'weight' => 0,
  );
  $response = $this
    ->servicesPost($path . '/taxonomy_vocabulary', $vocabulary);
  $query = db_select('taxonomy_vocabulary', 'v')
    ->fields('v', array(
    'vid',
  ))
    ->condition('v.name', $vocabulary['name']);
  $vid = $query
    ->execute()
    ->fetchField();
  $vocabulary_load = (array) taxonomy_vocabulary_load($vid);
  $vocabulary_intersect = array_intersect_assoc($vocabulary, $vocabulary_load);
  $this
    ->assertEqual($vocabulary, $vocabulary_intersect, 'Taxonomy vocabulary created properly.', 'TaxonomyVocabularyResource: Create');
}