public function RestfulEntityAndPropertyAccessTestCase::testPublicFieldAccess in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulEntityAndPropertyAccessTestCase.test \RestfulEntityAndPropertyAccessTestCase::testPublicFieldAccess()
Test access callback per public field.
File
- tests/
RestfulEntityAndPropertyAccessTestCase.test, line 198 - Contains RestfulEntityAndPropertyAccessTestCase
Class
- RestfulEntityAndPropertyAccessTestCase
- @file Contains RestfulEntityAndPropertyAccessTestCase
Code
public function testPublicFieldAccess() {
$settings = array(
'title' => 'no access',
'type' => 'article',
);
$node = $this
->drupalCreateNode($settings);
$handler = restful_get_restful_handler('test_articles');
$result = $handler
->get($node->nid);
$this
->assertTrue($result[0]['label'], 'Label access is allowed without access callback.');
$public_fields = $handler
->getPublicFields();
$public_fields['label']['access_callbacks'][] = array(
$this,
'publicFieldAccessFalse',
);
$handler
->setPublicFields($public_fields);
$result = $handler
->get($node->nid);
$this
->assertTrue(empty($result[0]['label']), 'Label access is denied with access callback.');
}