protected function RESTTestBase::enableService

Enables the REST service interface for a specific entity type.

Parameters

string|FALSE $resource_type: The resource type that should get REST API enabled or FALSE to disable all resource types.

string $method: The HTTP method to enable, e.g. GET, POST etc.

string $format: (Optional) The serialization format, e.g. hal_json.

5 calls to RESTTestBase::enableService()
CreateTest::testCreate in drupal/core/modules/rest/lib/Drupal/rest/Tests/CreateTest.php
Tests several valid and invalid create requests on all entity types.
DBLogTest::setUp in drupal/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php
Sets up a Drupal site for running functional and integration tests.
DeleteTest::testDelete in drupal/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php
Tests several valid and invalid delete requests on all entity types.
ReadTest::testRead in drupal/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php
Tests several valid and invalid read requests on all entity types.
UpdateTest::testPatchUpdate in drupal/core/modules/rest/lib/Drupal/rest/Tests/UpdateTest.php
Tests several valid and invalid partial update requests on test entities.

File

drupal/core/modules/rest/lib/Drupal/rest/Tests/RESTTestBase.php, line 187
Definition of Drupal\rest\test\RESTTestBase.

Class

RESTTestBase
Test helper class that provides a REST client method to send HTTP requests.

Namespace

Drupal\rest\Tests

Code

protected function enableService($resource_type, $method = 'GET', $format = NULL) {

  // Enable REST API for this entity type.
  $config = config('rest.settings');
  $settings = array();
  if ($resource_type) {
    if ($format) {
      $settings[$resource_type][$method][$format] = 'TRUE';
    }
    else {
      $settings[$resource_type][$method] = array();
    }
  }
  $config
    ->set('resources', $settings);
  $config
    ->save();

  // Rebuild routing cache, so that the REST API paths are available.
  drupal_container()
    ->get('router.builder')
    ->rebuild();

  // Reset the Simpletest permission cache, so that the new resource
  // permissions get picked up.
  drupal_static_reset('checkPermissions');
}