Loading core/modules/user/src/Form/UserPermissionsForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public function getFormId() { * An array of role objects. */ protected function getRoles() { return $this->roleStorage->loadMultiple(); return $this->roleStorage->loadMultipleOverrideFree(); } /** Loading core/modules/user/tests/modules/user_config_override_test/src/ConfigOverrider.php 0 → 100644 +49 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\user_config_override_test; use Drupal\Core\Config\StorableConfigBase; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; /** * Tests overridden permissions. */ class ConfigOverrider implements ConfigFactoryOverrideInterface { /** * {@inheritdoc} */ public function loadOverrides($names): array { return [ 'user.role.anonymous' => [ 'permissions' => [9999 => 'access content'], ], ]; } /** * {@inheritdoc} */ public function getCacheSuffix(): string { return 'user_config_override_test'; } /** * {@inheritdoc} */ public function getCacheableMetadata($name): CacheableMetadata { return new CacheableMetadata(); } /** * {@inheritdoc} */ public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION): StorableConfigBase|null { return NULL; } } core/modules/user/tests/modules/user_config_override_test/user_config_override_test.info.yml 0 → 100644 +4 −0 Original line number Diff line number Diff line name: 'Permission config overrider' type: module package: Testing version: VERSION core/modules/user/tests/modules/user_config_override_test/user_config_override_test.services.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line services: user_config_override_test.overrider: class: Drupal\user_config_override_test\ConfigOverrider tags: - { name: config.factory.override } core/modules/user/tests/src/Functional/UserPermissionsTest.php +19 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,13 @@ class UserPermissionsTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected static $modules = [ 'user_config_override_test', ]; /** * {@inheritdoc} */ Loading Loading @@ -331,4 +338,16 @@ public function testBundlePermissionError(): void { $assert_session->pageTextNotContains("Entity view display 'node.article.default': Component"); } /** * Verify that the permission form does not use overridden config. * * @see \Drupal\user_config_override_test\ConfigOverrider */ public function testOverriddenPermission(): void { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/people/permissions'); $this->assertSession()->checkboxNotChecked('anonymous[access content]'); } } Loading
core/modules/user/src/Form/UserPermissionsForm.php +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public function getFormId() { * An array of role objects. */ protected function getRoles() { return $this->roleStorage->loadMultiple(); return $this->roleStorage->loadMultipleOverrideFree(); } /** Loading
core/modules/user/tests/modules/user_config_override_test/src/ConfigOverrider.php 0 → 100644 +49 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\user_config_override_test; use Drupal\Core\Config\StorableConfigBase; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; /** * Tests overridden permissions. */ class ConfigOverrider implements ConfigFactoryOverrideInterface { /** * {@inheritdoc} */ public function loadOverrides($names): array { return [ 'user.role.anonymous' => [ 'permissions' => [9999 => 'access content'], ], ]; } /** * {@inheritdoc} */ public function getCacheSuffix(): string { return 'user_config_override_test'; } /** * {@inheritdoc} */ public function getCacheableMetadata($name): CacheableMetadata { return new CacheableMetadata(); } /** * {@inheritdoc} */ public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION): StorableConfigBase|null { return NULL; } }
core/modules/user/tests/modules/user_config_override_test/user_config_override_test.info.yml 0 → 100644 +4 −0 Original line number Diff line number Diff line name: 'Permission config overrider' type: module package: Testing version: VERSION
core/modules/user/tests/modules/user_config_override_test/user_config_override_test.services.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line services: user_config_override_test.overrider: class: Drupal\user_config_override_test\ConfigOverrider tags: - { name: config.factory.override }
core/modules/user/tests/src/Functional/UserPermissionsTest.php +19 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,13 @@ class UserPermissionsTest extends BrowserTestBase { */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected static $modules = [ 'user_config_override_test', ]; /** * {@inheritdoc} */ Loading Loading @@ -331,4 +338,16 @@ public function testBundlePermissionError(): void { $assert_session->pageTextNotContains("Entity view display 'node.article.default': Component"); } /** * Verify that the permission form does not use overridden config. * * @see \Drupal\user_config_override_test\ConfigOverrider */ public function testOverriddenPermission(): void { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/people/permissions'); $this->assertSession()->checkboxNotChecked('anonymous[access content]'); } }