public function RestfulGetHandlersTestCase::testGetHandlers in RESTful 7.2
Same name and namespace in other branches
- 7 tests/RestfulGetHandlersTestCase.test \RestfulGetHandlersTestCase::testGetHandlers()
Test getting handlers via API.
File
- tests/
RestfulGetHandlersTestCase.test, line 24 - Contains RestfulGetHandlersTestCase
Class
- RestfulGetHandlersTestCase
- @file Contains RestfulGetHandlersTestCase
Code
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.');
}