From 59a1ab2c45567f47ff67a3ef202b907a7e7a1a78 Mon Sep 17 00:00:00 2001 From: DYdave <DYdave@467284.no-reply.drupal.org> Date: Tue, 1 Apr 2025 09:49:54 +0200 Subject: [PATCH 01/12] Issue #3516579 by dydave: Automated testing on GitLab CI: Added initial configuration file '.gitlab-ci.yml' based on template and documentation from DO-3356364, to provide automated testing with GitLab CI pipelines. --- .gitlab-ci.yml | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a17ac9b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,95 @@ +################ +# GitLabCI template for Drupal projects. +# +# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. +# It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained. +# As long as you include the project, ref and three files below, any future updates added by the Drupal Association will be used in your +# pipelines automatically. However, you can modify this template if you have additional needs for your project. +# The full documentation is on https://project.pages.drupalcode.org/gitlab_templates/ +################ + +# For information on alternative values for 'ref' see https://project.pages.drupalcode.org/gitlab_templates/info/templates-version/ +# To test a Drupal 7 project, change the first include filename from .main.yml to .main-d7.yml +include: + - project: $_GITLAB_TEMPLATES_REPO + ref: $_GITLAB_TEMPLATES_REF + file: + - "/includes/include.drupalci.main.yml" + - "/includes/include.drupalci.variables.yml" + - "/includes/include.drupalci.workflows.yml" + +################ +# Pipeline configuration variables are defined with default values and descriptions in the file +# https://git.drupalcode.org/project/gitlab_templates/-/blob/main/includes/include.drupalci.variables.yml +# Uncomment the lines below if you want to override any of the variables. The following is just an example. +################ +# variables: +# SKIP_ESLINT: '1' +# OPT_IN_TEST_NEXT_MAJOR: '1' +# _CURL_TEMPLATES_REF: 'main' + +################ +# Custom Permissions: Pipeline configuration variables and custom jobs, mostly: +# - Broaden test coverage to all supported core versions and max PHP. +# - Require all jobs to pass: CSpell, ESLint, PHPCS, PHPSTAN and Stylelint. +################ + +variables: + ################ + # Opt in variables: Broaden test coverage. + ################ + OPT_IN_TEST_CURRENT: 1 + OPT_IN_TEST_PREVIOUS_MAJOR: 0 + OPT_IN_TEST_PREVIOUS_MINOR: 0 + OPT_IN_TEST_NEXT_MINOR: 0 + OPT_IN_TEST_NEXT_MAJOR: 0 + OPT_IN_TEST_MAX_PHP: 0 + # Speed up the execution of the Tests. + # _PHPUNIT_CONCURRENT: 1 + # # Convenient for debugging: Enable in issue forks for testing. + # _SHOW_ENVIRONMENT_VARIABLES: 1 + + # Strict PHPSTAN validation: Enforce the *maximum* rule level: 9. + # _PHPSTAN_LEVEL: 9 + +# # +# # CSPELL overrides and configuration. +# # +# cspell: +# # Require spellcheck to pass. +# allow_failure: false + +# # +# # ESLINT overrides and configuration. +# # +# eslint: +# # Require eslint to pass. +# allow_failure: false + +# # +# # PHPCS overrides and configuration. +# # +# phpcs: +# # Require phpcs to pass. +# allow_failure: false + +# # +# # PHPSTAN overrides and configuration. +# # +# phpstan: +# # Require phpstan to pass. +# allow_failure: false + +# # +# # PHPUNIT overrides and configuration. +# # +# phpunit: +# # Require phpunit to pass. +# allow_failure: false + +# # +# # STYLELINT overrides and configuration. +# # +# stylelint: +# # Require stylelint to pass. +# allow_failure: false -- GitLab From 595883ec7e1ec4620272d88b0fb74b0ea51a9345 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 14:06:19 -0500 Subject: [PATCH 02/12] Adding cspell disable to ignore spelling errors in the maintainer and supporting orgs sections. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ad0263f..097ae04 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ information, see See add/edit/delete permissions in /admin/people/custom-permissions/list. ## Maintainers +<!--- cspell:disable --> Alphabetical by username: @@ -59,3 +60,5 @@ Alphabetical by organization name: - [Agaric](https://www.drupal.org/agaric) - [Salsa Digital](https://www.drupal.org/salsa-digital) - [UTIKS](https://www.drupal.org/utiks) + +<!--- cspell:enable --> -- GitLab From 6a171f023dc6810657daaeed00ab621ccd22216d Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 14:15:34 -0500 Subject: [PATCH 03/12] Added function comments to ConfigPermsTest.php --- tests/src/Functional/ConfigPermsTest.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/src/Functional/ConfigPermsTest.php b/tests/src/Functional/ConfigPermsTest.php index 352e798..d607fe9 100644 --- a/tests/src/Functional/ConfigPermsTest.php +++ b/tests/src/Functional/ConfigPermsTest.php @@ -5,7 +5,11 @@ namespace Drupal\Tests\config_perms\Functional; use Drupal\Tests\BrowserTestBase; /** - * Tests that the perms are working. + * Functional tests for the config_perms module. + * + * Verifies that custom configuration permissions behave as expected, + * including default behavior, correct access restriction, and permission + * overrides. * * @group config_perms */ @@ -21,6 +25,12 @@ class ConfigPermsTest extends BrowserTestBase { */ protected static $modules = ['config_perms']; + /** + * Tests access to the custom permissions admin page based on permissions. + * + * Verifies that a user with 'administer config permissions' can access + * the page, while a user without it cannot. + */ public function testAdministerConfigPermsPermission() { $user_with_permission = $this->drupalCreateUser(['administer config permissions']); $user_without_permission = $this->drupalCreateUser(); @@ -39,7 +49,10 @@ class ConfigPermsTest extends BrowserTestBase { } /** - * Tests that the permissions are applied correctly. + * Tests that permissions are enforced for accessing account settings. + * + * Confirms that a user with the 'Administer account settings' permission + * can view the settings page, while one without cannot. */ public function testPermissions() { $user_with_permission = $this->drupalCreateUser(['Administer account settings']); @@ -57,11 +70,13 @@ class ConfigPermsTest extends BrowserTestBase { $this->drupalGet('admin/config/people/accounts'); $this->assertSession()->statusCodeEquals(403); $this->drupalLogout(); - } /** - * Tests that the permissions are overridden correctly. + * Tests that core permissions can be overridden by config_perms settings. + * + * Ensures that a user with the custom 'Administer account settings' permission + * has access, while a user with only the core permission does not. */ public function testOverridePermissions() { $user_custom_permission = $this->drupalCreateUser(['Administer account settings']); -- GitLab From 11cd500e70f7913561bedf443c2ca21f20c406b0 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 14:17:19 -0500 Subject: [PATCH 04/12] Addomg function comments to RouteSubscriber.php --- src/Routing/RouteSubscriber.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index 8e15245..11dd3bc 100755 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -7,15 +7,26 @@ use Symfony\Component\Routing\RouteCollection; use Drupal\config_perms\Entity\CustomPermsEntity; /** - * Class RouteSubscriber. + * Subscribes to route alterations for the config_perms module. + * + * Overrides route access requirements based on enabled custom permission + * entities. If a route is matched by a custom permission and the permission + * is active, the route's access control is replaced by the custom + * config_perms access checker. * * @package Drupal\config_perms\Routing - * Listens to the dynamic route events. */ class RouteSubscriber extends RouteSubscriberBase { /** - * {@inheritdoc} + * Alters existing routes to apply config_perms access control. + * + * This method loads all enabled CustomPermsEntity instances and applies + * their route definitions. If a matching route exists, its access + * requirements are overridden to use the _config_perms_access_check only. + * + * @param \Symfony\Component\Routing\RouteCollection $collection + * The collection of defined routes in the system. */ protected function alterRoutes(RouteCollection $collection) { $custom_perms = CustomPermsEntity::loadMultiple(); @@ -25,8 +36,7 @@ class RouteSubscriber extends RouteSubscriberBase { $routes = config_perms_parse_path($custom_perm->getRoute()); foreach ($routes as $route) { if ($route = $collection->get($route)) { - // This overrides the route requirements removing all the other - // access checkers and leaving only our access checker. + // Override route requirements to use only our custom access check. $route->setRequirements(['_config_perms_access_check' => 'TRUE']); } } -- GitLab From 1eccf0b7c3d1fdb01fcb801d5b150c641adf1732 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 14:20:55 -0500 Subject: [PATCH 05/12] Adding doc comments for ConfigPermListForm.php --- src/Form/ConfigPermListForm.php | 138 ++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 60 deletions(-) diff --git a/src/Form/ConfigPermListForm.php b/src/Form/ConfigPermListForm.php index 982c6f3..7523f64 100755 --- a/src/Form/ConfigPermListForm.php +++ b/src/Form/ConfigPermListForm.php @@ -10,28 +10,31 @@ use Drupal\Core\Routing\RouteProviderInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Class ConfigPermListForm. + * Provides the admin configuration form for managing custom permissions. + * + * Allows site administrators to enable, disable, edit, add, and delete + * route-based permissions for configuration access. * * @package Drupal\config_perms\Form */ class ConfigPermListForm extends FormBase { /** - * Router Provider service. + * The router provider service. * - * @var \Drupal\Core\Routing\RouteProvider + * @var \Drupal\Core\Routing\RouteProviderInterface */ protected $routerProvider; /** - * Router Builder service. + * The router builder service. * - * @var \Drupal\Core\Routing\RouteBuilder + * @var \Drupal\Core\Routing\RouteBuilderInterface */ protected $routerBuilder; /** - * Class constructor. + * Constructs a new ConfigPermListForm object. * * @param \Drupal\Core\Routing\RouteProviderInterface $router_provider * The router provider service. @@ -47,9 +50,7 @@ class ConfigPermListForm extends FormBase { * {@inheritdoc} */ public static function create(ContainerInterface $container) { - // Instantiates this form class. return new static( - // Load the service required to construct this class. $container->get('router.route_provider'), $container->get('router.builder') ); @@ -63,25 +64,37 @@ class ConfigPermListForm extends FormBase { } /** - * {@inheritdoc} + * Builds the permissions administration form. + * + * Displays a table of custom permissions with options to modify or add new ones. + * + * @param array $form + * The form array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The form state object. + * + * @return array + * The complete form render array. */ public function buildForm(array $form, FormStateInterface $form_state) { - + // Form initialization and description fieldset. $form['perms'] = [ '#type' => 'fieldset', '#title' => $this->t('Custom Permissions'), '#description' => '<p>' . $this->t("Please note that the order in which permissions are granted are as follows:") . '</p>' . - "<ul> - <li>" . $this->t("Custom permissions only support routes") . "</li>\n - <li>" . $this->t("User 1 still maintains full control") . "</li>\n - <li>" . $this->t("Remove the permission 'Administer site configuration' from roles you wish to give access to only specified custom site configuration permissions") . "</li>\n - </ul>", - '#collapsible' => 1, - '#collapsed' => 0, + "<ul> + <li>" . $this->t("Custom permissions only support routes") . "</li>\n + <li>" . $this->t("User 1 still maintains full control") . "</li>\n + <li>" . $this->t("Remove the permission 'Administer site configuration' from roles you wish to give access to only specified custom site configuration permissions") . "</li>\n + </ul>", + '#collapsible' => TRUE, + '#collapsed' => FALSE, ]; + // Load all existing custom permissions. $perms = CustomPermsEntity::loadMultiple(); + // Table header. $header = [ $this->t('Enabled'), $this->t('Name'), @@ -90,6 +103,7 @@ class ConfigPermListForm extends FormBase { '', ]; + // Setup the editable table. $form['perms']['local'] = [ '#type' => 'table', '#header' => $header, @@ -97,63 +111,46 @@ class ConfigPermListForm extends FormBase { '#suffix' => '</div>', ]; + // Populate table rows for each permission. /** @var \Drupal\config_perms\Entity\CustomPermsEntity $perm */ foreach ($perms as $key => $perm) { - $form['perms']['local'][$key] = ['#tree' => TRUE]; $form['perms']['local'][$key]['status'] = [ '#type' => 'checkbox', '#default_value' => $perm->status(), ]; - $form['perms']['local'][$key]['name'] = [ '#type' => 'textfield', '#default_value' => $perm->label(), '#size' => 30, ]; - $form['perms']['local'][$key]['route'] = [ '#type' => 'textarea', '#default_value' => $perm->getRoute(), '#size' => 50, '#rows' => 1, ]; - - // Delete link. - $delete_link = $perm->toLink($this->t('Delete'), 'delete-form'); - $form['perms']['local'][$key]['delete'] = $delete_link->toRenderable(); + $form['perms']['local'][$key]['delete'] = $perm->toLink($this->t('Delete'), 'delete-form')->toRenderable(); $form['perms']['local'][$key]['id'] = [ '#type' => 'hidden', '#default_value' => $perm->id(), ]; } - $num_new = $form_state->getValue('num_new'); - if (empty($num_new)) { - $form_state->setValue('num_new', '0'); - } - - for ($i = 0; $i < $form_state->getValue('num_new'); $i++) { - $form['perms']['local']['new']['status'] = [ - '#type' => 'checkbox', - '#default_value' => '', - ]; - $form['perms']['local']['new']['name'] = [ - '#type' => 'textfield', - '#default_value' => '', - '#size' => 30, - ]; + // Initialize new row handling. + $num_new = $form_state->getValue('num_new') ?? 0; + $form_state->setValue('num_new', $num_new); - $form['perms']['local']['new']['route'] = [ - '#type' => 'textarea', - '#default_value' => '', - '#rows' => 2, - '#size' => 50, + for ($i = 0; $i < $num_new; $i++) { + $form['perms']['local']['new'] = [ + 'status' => ['#type' => 'checkbox'], + 'name' => ['#type' => 'textfield', '#size' => 30], + 'route' => ['#type' => 'textarea', '#rows' => 2, '#size' => 50], ]; - } + // Add permission button. $form['perms']['add']['status'] = [ '#name' => 'status', '#id' => 'edit-local-status', @@ -166,6 +163,7 @@ class ConfigPermListForm extends FormBase { ], ]; + // Save button. $form['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save'), @@ -175,14 +173,29 @@ class ConfigPermListForm extends FormBase { } /** - * Callback for add button. + * AJAX callback to refresh the table after adding a new permission. + * + * @param array $form + * The form array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The form state object. + * + * @return array + * The rendered portion of the form to update. */ public function configPermsAdminFormAddCallback($form, $form_state) { return $form['perms']['local']; } /** - * Submit for add button. + * Submit handler for the "Add permission" button. + * + * Increments the number of new permission rows. + * + * @param array $form + * The form array. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * The form state object. */ public function configPermsAdminFormAddSubmit($form, &$form_state) { $form_state->setValue('num_new', $form_state->getValue('num_new') + 1); @@ -197,27 +210,24 @@ class ConfigPermListForm extends FormBase { $perms = CustomPermsEntity::loadMultiple(); foreach ($values['local'] as $key => $perm) { - - if (empty($perm['name']) && empty($perm['route']) && $key != 'new') { - $entity = CustomPermsEntity::load($perm['id']); - $entity->delete(); + if (empty($perm['name']) && empty($perm['route']) && $key !== 'new') { + CustomPermsEntity::load($perm['id'])->delete(); } else { if (empty($perm['name'])) { - $form_state->setErrorByName("local][" . $key . "", $this->t("The name cannot be empty.")); + $form_state->setErrorByName("local][$key", $this->t("The name cannot be empty.")); } - if (empty($perm['route'])) { - $form_state->setErrorByName("local][" . $key . "", $this->t("The route cannot be empty.")); + $form_state->setErrorByName("local][$key", $this->t("The route cannot be empty.")); } if (array_key_exists($this->configPermsGenerateMachineName($perm['name']), $perms) && !isset($perm['id'])) { - $form_state->setErrorByName("local][" . $key . "", $this->t("A permission with that name already exists.")); + $form_state->setErrorByName("local][$key", $this->t("A permission with that name already exists.")); } if (!empty($perm['route'])) { $routes = config_perms_parse_path($perm['route']); foreach ($routes as $route) { if (count($this->routerProvider->getRoutesByNames([$route])) < 1) { - $form_state->setErrorByName("local][" . $key . "", $this->t("The route @route is invalid.", ['@route' => $perm['route']])); + $form_state->setErrorByName("local][$key", $this->t("The route @route is invalid.", ['@route' => $perm['route']])); } } } @@ -233,15 +243,14 @@ class ConfigPermListForm extends FormBase { $perms = CustomPermsEntity::loadMultiple(); foreach ($values['local'] as $key => $data) { - // If new permission. - if ($key == 'new') { + if ($key === 'new') { $entity = CustomPermsEntity::create(); $entity->set('id', $this->configPermsGenerateMachineName($data['name'])); } else { - // Update || Insert. $entity = $perms[$data['id']]; } + $entity->set('label', $data['name']); $entity->set('route', $data['route']); $entity->set('status', $data['status']); @@ -253,7 +262,16 @@ class ConfigPermListForm extends FormBase { } /** - * Generate a machine name given a string. + * Generates a machine name from a string. + * + * Converts a string to a lowercase, underscore-separated format suitable + * for use as an ID. + * + * @param string $string + * The human-readable string. + * + * @return string + * The machine-friendly identifier. */ public function configPermsGenerateMachineName($string) { return strtolower(preg_replace('/[^a-zA-Z0-9_]+/', '_', $string)); -- GitLab From e626892d2fd4ca3ce67f563f543b0cec1504b24f Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 14:25:16 -0500 Subject: [PATCH 06/12] Adding descriptice comments --- config_perms.install | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/config_perms.install b/config_perms.install index db2d4cf..7dd2cac 100644 --- a/config_perms.install +++ b/config_perms.install @@ -1,7 +1,13 @@ <?php /** - * Updates the paths to its entities. + * Converts old path-based permission entries to route-based entries. + * + * Parses the 'path' value of each custom permission config entity and + * attempts to resolve it to a route name. If successful, replaces the + * 'path' key with a 'route' key in the configuration. + * + * This ensures all custom permissions are stored in route-based format. */ function config_perms_update_8201() { $config_factory = \Drupal::configFactory(); @@ -31,7 +37,11 @@ function config_perms_update_8201() { } /** - * Adds the "administer config permissions" permission. + * Grants new "administer config permissions" to roles with site config access. + * + * Ensures backward compatibility by granting the new, more specific permission + * to any role that previously had the broader + * "administer site configuration" permission. */ function config_perms_update_8202() { $roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple(); @@ -40,6 +50,7 @@ function config_perms_update_8202() { // There is now a dedicated permission to configure the module, to keep the // things working let's provide this new permission to the users that were // already able to configure the module before. + // Assign new permission to preserve current access for administrators. if ($role->hasPermission('administer site configuration')) { $role->grantPermission('administer config permissions'); $role->save(); -- GitLab From 5db3aa8d435c29c5d5e864621ee13fe16477ff45 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 14:32:53 -0500 Subject: [PATCH 07/12] Replace drupal class call with dependency injection --- src/Form/CustomPermsEntityDeleteForm.php | 39 +++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/src/Form/CustomPermsEntityDeleteForm.php b/src/Form/CustomPermsEntityDeleteForm.php index e2bef0b..1fbd345 100755 --- a/src/Form/CustomPermsEntityDeleteForm.php +++ b/src/Form/CustomPermsEntityDeleteForm.php @@ -4,6 +4,7 @@ namespace Drupal\config_perms\Form; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Routing\RouteBuilderInterface; use Drupal\Core\Url; /** @@ -11,6 +12,32 @@ use Drupal\Core\Url; */ class CustomPermsEntityDeleteForm extends EntityConfirmFormBase { + /** + * The router builder. + * + * @var \Drupal\Core\Routing\RouteBuilderInterface + */ + protected $routerBuilder; + + /** + * Constructs a new CustomPermsEntityDeleteForm. + * + * @param \Drupal\Core\Routing\RouteBuilderInterface $router_builder + * The router builder service. + */ + public function __construct(RouteBuilderInterface $router_builder) { + $this->routerBuilder = $router_builder; + } + + /** + * {@inheritdoc} + */ + public static function create($container) { + return new static( + $container->get('router.builder') + ); + } + /** * {@inheritdoc} */ @@ -39,15 +66,13 @@ class CustomPermsEntityDeleteForm extends EntityConfirmFormBase { $this->entity->delete(); $this->messenger()->addMessage( - $this->t('content @type: deleted @label.', - [ - '@type' => $this->entity->bundle(), - '@label' => $this->entity->label(), - ] - ) + $this->t('content @type: deleted @label.', [ + '@type' => $this->entity->bundle(), + '@label' => $this->entity->label(), + ]) ); - \Drupal::service('router.builder')->rebuild(); + $this->routerBuilder->rebuild(); $form_state->setRedirectUrl($this->getCancelUrl()); } -- GitLab From b47ec1e28a75817e909945245fec36c55061e4b5 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 15:23:27 -0500 Subject: [PATCH 08/12] Fixing spelling error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 097ae04..fa641e7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This very lightweight module allows additional permissions to be created and managed through an administration form. It uses the menu access system to allow -or dissalow access. +or disallow access. On an administration page, a user is able to create a permission with name and paths. These permissions can then be assigned to roles on the permissions page. -- GitLab From b080acbe2eacc020b4fd4918ca88034db7568383 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 15:23:39 -0500 Subject: [PATCH 09/12] Fixing line lengths --- src/Form/ConfigPermListForm.php | 3 ++- tests/src/Functional/ConfigPermsTest.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Form/ConfigPermListForm.php b/src/Form/ConfigPermListForm.php index 7523f64..f3ace8d 100755 --- a/src/Form/ConfigPermListForm.php +++ b/src/Form/ConfigPermListForm.php @@ -66,7 +66,8 @@ class ConfigPermListForm extends FormBase { /** * Builds the permissions administration form. * - * Displays a table of custom permissions with options to modify or add new ones. + * Displays a table of custom permissions with options to modify or add new + * ones. * * @param array $form * The form array. diff --git a/tests/src/Functional/ConfigPermsTest.php b/tests/src/Functional/ConfigPermsTest.php index d607fe9..8b8218b 100644 --- a/tests/src/Functional/ConfigPermsTest.php +++ b/tests/src/Functional/ConfigPermsTest.php @@ -75,8 +75,8 @@ class ConfigPermsTest extends BrowserTestBase { /** * Tests that core permissions can be overridden by config_perms settings. * - * Ensures that a user with the custom 'Administer account settings' permission - * has access, while a user with only the core permission does not. + * Ensures that a user with the custom 'Administer account settings' + * permission has access, while a user with only the core permission does not. */ public function testOverridePermissions() { $user_custom_permission = $this->drupalCreateUser(['Administer account settings']); -- GitLab From aa60d3973f2fd620c15ee5afb0a014238c482557 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 15:36:04 -0500 Subject: [PATCH 10/12] Fixing spacing issues --- config_perms.install | 4 ++++ src/Form/ConfigPermListForm.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config_perms.install b/config_perms.install index 7dd2cac..63738a2 100644 --- a/config_perms.install +++ b/config_perms.install @@ -1,5 +1,9 @@ <?php +/** + * @file + */ + /** * Converts old path-based permission entries to route-based entries. * diff --git a/src/Form/ConfigPermListForm.php b/src/Form/ConfigPermListForm.php index f3ace8d..eca8534 100755 --- a/src/Form/ConfigPermListForm.php +++ b/src/Form/ConfigPermListForm.php @@ -83,7 +83,7 @@ class ConfigPermListForm extends FormBase { '#type' => 'fieldset', '#title' => $this->t('Custom Permissions'), '#description' => '<p>' . $this->t("Please note that the order in which permissions are granted are as follows:") . '</p>' . - "<ul> + "<ul> <li>" . $this->t("Custom permissions only support routes") . "</li>\n <li>" . $this->t("User 1 still maintains full control") . "</li>\n <li>" . $this->t("Remove the permission 'Administer site configuration' from roles you wish to give access to only specified custom site configuration permissions") . "</li>\n -- GitLab From 1b3f5cfa15274f56886f528c07c50573e5a52081 Mon Sep 17 00:00:00 2001 From: Wilbur Ince <wilbur@wilbur.us> Date: Thu, 22 May 2025 15:49:54 -0500 Subject: [PATCH 11/12] Adding comment to file tag --- config_perms.install | 1 + 1 file changed, 1 insertion(+) diff --git a/config_perms.install b/config_perms.install index 63738a2..79aa05a 100644 --- a/config_perms.install +++ b/config_perms.install @@ -2,6 +2,7 @@ /** * @file + * Contains update hooks for the Config Perms module. */ /** -- GitLab From 13520e9bcbbfb222aae238c84ce69134e3aade38 Mon Sep 17 00:00:00 2001 From: DYdave <DYdave@467284.no-reply.drupal.org> Date: Fri, 23 May 2025 15:45:50 +0200 Subject: [PATCH 12/12] Broadened Tests coverage and required all jobs to pass. --- .gitlab-ci.yml | 60 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a17ac9b..faa3f5e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -39,46 +39,46 @@ variables: # Opt in variables: Broaden test coverage. ################ OPT_IN_TEST_CURRENT: 1 - OPT_IN_TEST_PREVIOUS_MAJOR: 0 - OPT_IN_TEST_PREVIOUS_MINOR: 0 - OPT_IN_TEST_NEXT_MINOR: 0 - OPT_IN_TEST_NEXT_MAJOR: 0 - OPT_IN_TEST_MAX_PHP: 0 + OPT_IN_TEST_PREVIOUS_MAJOR: 1 + OPT_IN_TEST_PREVIOUS_MINOR: 1 + OPT_IN_TEST_NEXT_MINOR: 1 + OPT_IN_TEST_NEXT_MAJOR: 1 + OPT_IN_TEST_MAX_PHP: 1 # Speed up the execution of the Tests. - # _PHPUNIT_CONCURRENT: 1 + _PHPUNIT_CONCURRENT: 1 # # Convenient for debugging: Enable in issue forks for testing. # _SHOW_ENVIRONMENT_VARIABLES: 1 # Strict PHPSTAN validation: Enforce the *maximum* rule level: 9. # _PHPSTAN_LEVEL: 9 -# # -# # CSPELL overrides and configuration. -# # -# cspell: -# # Require spellcheck to pass. -# allow_failure: false +# +# CSPELL overrides and configuration. +# +cspell: + # Require spellcheck to pass. + allow_failure: false -# # -# # ESLINT overrides and configuration. -# # -# eslint: -# # Require eslint to pass. -# allow_failure: false +# +# ESLINT overrides and configuration. +# +eslint: + # Require eslint to pass. + allow_failure: false -# # -# # PHPCS overrides and configuration. -# # -# phpcs: -# # Require phpcs to pass. -# allow_failure: false +# +# PHPCS overrides and configuration. +# +phpcs: + # Require phpcs to pass. + allow_failure: false -# # -# # PHPSTAN overrides and configuration. -# # -# phpstan: -# # Require phpstan to pass. -# allow_failure: false +# +# PHPSTAN overrides and configuration. +# +phpstan: + # Require phpstan to pass. + allow_failure: false # # # # PHPUNIT overrides and configuration. -- GitLab