You are here

public function RestfulCreateTaxonomyTermTestCase::testCreate in RESTful 7.2

Same name and namespace in other branches
  1. 7 tests/RestfulCreateTaxonomyTermTestCase.test \RestfulCreateTaxonomyTermTestCase::testCreate()

Test the creation of a taxonomy term entity type.

File

tests/RestfulCreateTaxonomyTermTestCase.test, line 28
Contains RestfulCreateTaxonomyTermTestCase

Class

RestfulCreateTaxonomyTermTestCase

Code

public function testCreate() {
  $resource_manager = restful()
    ->getResourceManager();
  $user1 = $this
    ->drupalCreateUser(array(
    'create article content',
  ));
  $this
    ->drupalLogin($user1);
  $handler = $resource_manager
    ->getPlugin('test_tags:1.0');
  $handler
    ->setAccount($user1);
  $text1 = $this
    ->randomName();
  $request = array(
    'label' => $text1,
  );
  $handler
    ->setRequest(Request::create('', array(), RequestInterface::METHOD_POST, NULL, FALSE, NULL, array(), array(), array(), $request));
  $handler
    ->setPath('');
  $result = drupal_json_decode(restful()
    ->getFormatterManager()
    ->format($handler
    ->process(), 'json'));
  $result = $result['data'];
  $id = $result[0]['id'];
  $this
    ->assertTrue($id, 'Term was created by a non-admin user.');
}