You are here

function ServicesResourceTaxonomyTests::testTermCreateLegacy in Services 7.3

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

Test taxonomy term create method (Legacy).

TODO: To be removed in future version.

See also

http://drupal.org/node/1083242

File

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

Class

ServicesResourceTaxonomyTests
Taxonomy resource test class.

Code

function testTermCreateLegacy() {
  $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', array(
    '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, 'Taxonomy term created properly.', 'TaxonomyTermResource: Create (Legacy)');
}