You are here

function ServicesResourceTaxonomyTests::testTermCreate in Services 6.3

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

Test taxonomy term create method.

File

tests/functional/ServicesResourceTaxonomyTests.test, line 240

Class

ServicesResourceTaxonomyTests
Run test cases for the endpoint with no authentication turned on.

Code

function testTermCreate() {
  $path = $this->endpoint->path;
  $vocabulary = $this
    ->createVocabulary();
  $term = array(
    'vid' => $vocabulary['vid'],
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomString(),
    'weight' => rand(0, 100),
    'parent' => NULL,
  );
  $response = $this
    ->servicesPost($path . '/taxonomy_term', $term);

  // Load term by name.
  $term_by_name = (array) current(taxonomy_get_term_by_name($term['name']));
  $term_intersect = array_intersect_assoc($term, $term_by_name);

  // As term_intersect will not have parent, we unset this property.
  $term_data = $term;
  unset($term_data['parent']);
  $this
    ->assertEqual($term_data, $term_intersect, t('Taxonomy term created properly.'), 'TaxonomyTermResource: Create');
}