You are here

RestfulGetHandlersTestCase.test in RESTful 7.2

Same filename and directory in other branches
  1. 7 tests/RestfulGetHandlersTestCase.test

Contains RestfulGetHandlersTestCase

File

tests/RestfulGetHandlersTestCase.test
View source
<?php

/**
 * @file
 * Contains RestfulGetHandlersTestCase
 */
class RestfulGetHandlersTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Get handlers',
      'description' => 'Test getting handlers by version (major and minor).',
      'group' => 'RESTful',
    );
  }
  public function setUp() {
    parent::setUp('restful_example');
  }

  /**
   * Test getting handlers via API.
   */
  public function testGetHandlers() {
    $resource_manager = restful()
      ->getResourceManager();
    $title = $this
      ->randomName();
    $settings = array(
      'type' => 'article',
      'title' => $title,
    );
    $node1 = $this
      ->drupalCreateNode($settings);
    $handler = $resource_manager
      ->getPlugin('articles:1.1');
    $this
      ->assertTrue($handler instanceof \Drupal\restful_example\Plugin\resource\node\article\v1\Articles__1_0);
    $handler
      ->setRequest(\Drupal\restful\Http\Request::create('articles/v1.1/' . $node1->nid));
    $handler
      ->setPath($node1->nid);
    $response = drupal_json_decode(restful()
      ->getFormatterManager()
      ->format($handler
      ->process(), 'json'));
    $response = $response['data'];
    $result = $response[0];
    $this
      ->assertTrue(empty($result['self']), '"self" property does not appear in minor version 1.');
  }

}

Classes

Namesort descending Description
RestfulGetHandlersTestCase @file Contains RestfulGetHandlersTestCase