public function RestLinkManagerTest::testRestLinkManagersNoInstallHook in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/Tests/RestLinkManagerTest.php \Drupal\rest\Tests\RestLinkManagerTest::testRestLinkManagersNoInstallHook()
Tests that type hooks work as expected even without install hook.
File
- core/
modules/ rest/ src/ Tests/ RestLinkManagerTest.php, line 58 - Contains \Drupal\rest\Tests\RestLinkManagerTest.
Class
- RestLinkManagerTest
- Tests that REST type and relation link managers work as expected @group rest
Namespace
Drupal\rest\TestsCode
public function testRestLinkManagersNoInstallHook() {
/* @var \Drupal\rest\LinkManager\TypeLinkManagerInterface $type_manager */
$type_manager = \Drupal::service('rest.link_manager.type');
$base = Url::fromRoute('<front>', [], [
'absolute' => TRUE,
])
->toString();
$link = $type_manager
->getTypeUri('node', 'page');
$this
->assertEqual($link, $base . 'rest/type/node/page');
// Now with optional context.
$link = $type_manager
->getTypeUri('node', 'page', [
'rest_test' => TRUE,
]);
$this
->assertEqual($link, 'rest_test_type');
/* @var \Drupal\rest\LinkManager\RelationLinkManagerInterface $relation_manager */
$relation_manager = \Drupal::service('rest.link_manager.relation');
$link = $relation_manager
->getRelationUri('node', 'page', 'field_ref');
$this
->assertEqual($link, $base . 'rest/relation/node/page/field_ref');
// Now with optional context.
$link = $relation_manager
->getRelationUri('node', 'page', 'foobar', [
'rest_test' => TRUE,
]);
$this
->assertEqual($link, 'rest_test_relation');
}