Loading core/modules/user/src/Form/EntityPermissionsForm.php +3 −4 Original line number Diff line number Diff line Loading @@ -93,11 +93,10 @@ protected function permissionsByProvider(): array { // Get the names of all config entities that depend on $this->bundle. $config_name = $this->bundle->getConfigDependencyName(); $config_entities = $this->configManager ->getConfigEntitiesToChangeOnDependencyRemoval('config', [$config_name]); ->findConfigEntityDependencies('config', [$config_name]); $config_names = array_map( function ($dependent_config) { return $dependent_config->getConfigDependencyName(); }, $config_entities['delete'] ?? [] fn($dependent_config) => $dependent_config->getConfigDependencyName(), $config_entities, ); $config_names[] = $config_name; Loading core/modules/user/tests/src/Functional/UserPermissionsTest.php +35 −1 Original line number Diff line number Diff line Loading @@ -4,9 +4,10 @@ namespace Drupal\Tests\user\Functional; use Drupal\comment\Tests\CommentTestTrait; use Drupal\Tests\BrowserTestBase; use Drupal\user\RoleInterface; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; /** * Verifies role permissions can be added and removed via the permissions page. Loading @@ -15,6 +16,8 @@ */ class UserPermissionsTest extends BrowserTestBase { use CommentTestTrait; /** * User with admin privileges. * Loading Loading @@ -297,4 +300,35 @@ public function testAccessBundlePermission(): void { $this->assertSession()->statusCodeEquals(403); } /** * Tests that access check does not trigger warnings. * * The access check for /admin/structure/comment/manage/comment/permissions is * \Drupal\user\Form\EntityPermissionsForm::EntityPermissionsForm::access(). */ public function testBundlePermissionError(): void { \Drupal::service('module_installer')->install(['comment', 'dblog', 'field_ui', 'node']); // Set up the node and comment field. Use the 'default' view mode since // 'full' is not defined, so it will not be added to the config entity. $this->drupalCreateContentType(['type' => 'article']); $this->addDefaultCommentField('node', 'article', comment_view_mode: 'default'); $this->drupalLogin($this->adminUser); $this->grantPermissions(Role::load($this->rid), ['access site reports', 'administer comment display']); // Access both the Manage display and permission page, which is not // accessible currently. $assert_session = $this->assertSession(); $this->drupalGet('/admin/structure/comment/manage/comment/display'); $assert_session->statusCodeEquals(200); $this->drupalGet('/admin/structure/comment/manage/comment/permissions'); $assert_session->statusCodeEquals(403); // Ensure there are no warnings in the log. $this->drupalGet('/admin/reports/dblog'); $assert_session->statusCodeEquals(200); $assert_session->pageTextContains('access denied'); $assert_session->pageTextNotContains("Entity view display 'node.article.default': Component"); } } core/modules/user/tests/src/Unit/Form/EntityPermissionsFormTest.php +3 −5 Original line number Diff line number Diff line Loading @@ -60,12 +60,10 @@ public function testPermissionsByProvider(string $dependency_name, bool $found): $module_handler = $this->prophesize(ModuleHandlerInterface::class)->reveal(); $module_extension_list = $this->prophesize(ModuleExtensionList::class)->reveal(); $prophecy = $this->prophesize(ConfigManagerInterface::class); $prophecy->getConfigEntitiesToChangeOnDependencyRemoval('config', ['node.type.article']) $prophecy->findConfigEntityDependencies('config', ['node.type.article']) ->willReturn([ 'delete' => [ new ConfigEntityDependency('core.entity_view_display.node.article.full'), new ConfigEntityDependency('field.field.node.article.body'), ], ]); $config_manager = $prophecy->reveal(); $prophecy = $this->prophesize(EntityTypeInterface::class); Loading Loading
core/modules/user/src/Form/EntityPermissionsForm.php +3 −4 Original line number Diff line number Diff line Loading @@ -93,11 +93,10 @@ protected function permissionsByProvider(): array { // Get the names of all config entities that depend on $this->bundle. $config_name = $this->bundle->getConfigDependencyName(); $config_entities = $this->configManager ->getConfigEntitiesToChangeOnDependencyRemoval('config', [$config_name]); ->findConfigEntityDependencies('config', [$config_name]); $config_names = array_map( function ($dependent_config) { return $dependent_config->getConfigDependencyName(); }, $config_entities['delete'] ?? [] fn($dependent_config) => $dependent_config->getConfigDependencyName(), $config_entities, ); $config_names[] = $config_name; Loading
core/modules/user/tests/src/Functional/UserPermissionsTest.php +35 −1 Original line number Diff line number Diff line Loading @@ -4,9 +4,10 @@ namespace Drupal\Tests\user\Functional; use Drupal\comment\Tests\CommentTestTrait; use Drupal\Tests\BrowserTestBase; use Drupal\user\RoleInterface; use Drupal\user\Entity\Role; use Drupal\user\RoleInterface; /** * Verifies role permissions can be added and removed via the permissions page. Loading @@ -15,6 +16,8 @@ */ class UserPermissionsTest extends BrowserTestBase { use CommentTestTrait; /** * User with admin privileges. * Loading Loading @@ -297,4 +300,35 @@ public function testAccessBundlePermission(): void { $this->assertSession()->statusCodeEquals(403); } /** * Tests that access check does not trigger warnings. * * The access check for /admin/structure/comment/manage/comment/permissions is * \Drupal\user\Form\EntityPermissionsForm::EntityPermissionsForm::access(). */ public function testBundlePermissionError(): void { \Drupal::service('module_installer')->install(['comment', 'dblog', 'field_ui', 'node']); // Set up the node and comment field. Use the 'default' view mode since // 'full' is not defined, so it will not be added to the config entity. $this->drupalCreateContentType(['type' => 'article']); $this->addDefaultCommentField('node', 'article', comment_view_mode: 'default'); $this->drupalLogin($this->adminUser); $this->grantPermissions(Role::load($this->rid), ['access site reports', 'administer comment display']); // Access both the Manage display and permission page, which is not // accessible currently. $assert_session = $this->assertSession(); $this->drupalGet('/admin/structure/comment/manage/comment/display'); $assert_session->statusCodeEquals(200); $this->drupalGet('/admin/structure/comment/manage/comment/permissions'); $assert_session->statusCodeEquals(403); // Ensure there are no warnings in the log. $this->drupalGet('/admin/reports/dblog'); $assert_session->statusCodeEquals(200); $assert_session->pageTextContains('access denied'); $assert_session->pageTextNotContains("Entity view display 'node.article.default': Component"); } }
core/modules/user/tests/src/Unit/Form/EntityPermissionsFormTest.php +3 −5 Original line number Diff line number Diff line Loading @@ -60,12 +60,10 @@ public function testPermissionsByProvider(string $dependency_name, bool $found): $module_handler = $this->prophesize(ModuleHandlerInterface::class)->reveal(); $module_extension_list = $this->prophesize(ModuleExtensionList::class)->reveal(); $prophecy = $this->prophesize(ConfigManagerInterface::class); $prophecy->getConfigEntitiesToChangeOnDependencyRemoval('config', ['node.type.article']) $prophecy->findConfigEntityDependencies('config', ['node.type.article']) ->willReturn([ 'delete' => [ new ConfigEntityDependency('core.entity_view_display.node.article.full'), new ConfigEntityDependency('field.field.node.article.body'), ], ]); $config_manager = $prophecy->reveal(); $prophecy = $this->prophesize(EntityTypeInterface::class); Loading