You are here

public function RestfulEntityAndPropertyAccessTestCase::testEndPointAccessCallback in RESTful 7

Same name and namespace in other branches
  1. 7.2 tests/RestfulEntityAndPropertyAccessTestCase.test \RestfulEntityAndPropertyAccessTestCase::testEndPointAccessCallback()

Tests custom access callbacks at the resource method level.

File

tests/RestfulEntityAndPropertyAccessTestCase.test, line 176
Contains RestfulEntityAndPropertyAccessTestCase

Class

RestfulEntityAndPropertyAccessTestCase
@file Contains RestfulEntityAndPropertyAccessTestCase

Code

public function testEndPointAccessCallback() {
  $settings = array(
    'type' => 'article',
  );
  $node = $this
    ->drupalCreateNode($settings);
  $handler = restful_get_restful_handler('test_articles', 1, 3);
  try {
    $handler
      ->get($node->nid);
    $this
      ->fail('Custom access callback per resource\'s method not executed correctly.');
  } catch (\RestfulForbiddenException $e) {
    $this
      ->pass('Custom access callback per endpoint executed correctly.');
  }
  $handler
    ->head($node->nid);
  $this
    ->pass('Custom access callback per endpoint executed correctly.');
}