You are here

RestfulGetHandlersTestCase.test in RESTful 7

Same filename and directory in other branches
  1. 7.2 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',
    );
  }
  function setUp() {
    parent::setUp('restful_example');
  }

  /**
   * Test getting handlers via API.
   */
  function testGetHandlers() {
    $title = $this
      ->randomName();
    $settings = array(
      'type' => 'article',
      'title' => $title,
    );
    $node1 = $this
      ->drupalCreateNode($settings);
    $handler = restful_get_restful_handler('articles');
    $this
      ->assertEqual(get_class($handler), 'RestfulExampleArticlesResource');
    $response = $handler
      ->get($node1->nid);
    $result = $response[0];
    $this
      ->assertTrue(!empty($result['self']), '"self" property appears in minor version 0.');
    $handler = restful_get_restful_handler('articles', 1, 1);
    $this
      ->assertEqual(get_class($handler), 'RestfulExampleArticlesResource__1_1');
    $response = $handler
      ->get($node1->nid);
    $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