You are here

function ServicesResourceTaxonomyTests::testTermCreateLegacy in Services 6.3

Same name and namespace in other branches
  1. 7.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 272

Class

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

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, t('Taxonomy term created properly.'), 'TaxonomyTermResource: Create (Legacy)');
}