public function RelationHandlerTest::testDecoratorChain in Group 2.0.x
Tests that decorators can target all plugins or one in specific.
File
- tests/
src/ Kernel/ RelationHandlerTest.php, line 36
Class
- RelationHandlerTest
- Tests that relation handlers work as expected.
Namespace
Drupal\Tests\group\KernelCode
public function testDecoratorChain() {
/** @var \Drupal\group\Plugin\Group\Relation\GroupRelationManagerInterface $relation_manager */
$relation_manager = $this->container
->get('plugin.manager.group_relation');
$message = "All plugins have foobar appended, proving decorating defaults works and respects priority";
$expected = 'administer user_as_content' . 'foobar';
$this
->assertSame($expected, $relation_manager
->getPermissionProvider('user_as_content')
->getAdminPermission(), $message);
$message = "Node plugin also has baz appended, proving decoration_priority works separately for the default and specific service";
$expected = 'administer node_as_content:page' . 'foobar' . 'baz';
$this
->assertSame($expected, $relation_manager
->getPermissionProvider('node_as_content:page')
->getAdminPermission(), $message);
$message = "Test entity plugin also has bazfoo appended, proving decoration_priority is respected within specific alters";
$expected = 'administer entity_test_as_content' . 'foobar' . 'bazfoo';
$this
->assertSame($expected, $relation_manager
->getPermissionProvider('entity_test_as_content')
->getAdminPermission(), $message);
}