Skip to content
Snippets Groups Projects

Issue #3439905: Fix shortcut tests

5 unresolved threads

Closes #3439905

Merge request reports

Members who can merge are allowed to add commits.

Merge request pipeline #150418 passed

Merge request pipeline passed for f4b4255e

Code Quality is loading
Test summary results are being parsed
Ready to merge by members who can write to the target branch.
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
228 245 'label' => 'Basic block',
229 246 'revision' => FALSE,
230 247 ])->save();
248 $user_role = Role::load(RoleInterface::AUTHENTICATED_ID);
  • 29 29 'shortcut',
    30 30 'test_page_test',
    31 31 'block',
    32 'node',
  • 29 29 'shortcut',
    30 30 'test_page_test',
    31 31 'block',
    32 'node',
    32 33 ];
    33 34
    34 35 /**
    35 * {@inheritdoc}
    36 * User with permission to administer shortcuts.
    36 37 *
    37 * @todo Remove and fix test to not rely on super user.
    38 * @see https://www.drupal.org/project/drupal/issues/3437620
    38 * @var \Drupal\user\UserInterface
    39 39 */
    40 protected bool $usesSuperUserAccessPolicy = TRUE;
    40 protected $adminUser;
  • 32 34 protected static $modules = ['router_test', 'views', 'block'];
    33 35
    34 36 /**
    35 * {@inheritdoc}
    37 * User with permission to administer shortcuts.
    36 38 *
    37 * @todo Remove and fix test to not rely on super user.
    38 * @see https://www.drupal.org/project/drupal/issues/3437620
    39 * @var \Drupal\user\UserInterface
    39 40 */
    40 protected bool $usesSuperUserAccessPolicy = TRUE;
    41 protected $adminUser;
  • Soliman Harkas added 2 commits

    added 2 commits

    • bdc405a0 - Issue #3439905: Load role using entity manager in shout link test
    • b9155e7d - Issue #3439905: Specify type for admin User property in shortcut cache tags test

    Compare with previous version

  • added 1 commit

    • bd1975fb - Apply 1 suggestion(s) to 1 file(s)

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • 228 242 'label' => 'Basic block',
    229 243 'revision' => FALSE,
    230 244 ])->save();
    245 $user_role = \Drupal::entityTypeManager()->getStorage('user_role')->load(RoleInterface::AUTHENTICATED_ID);
    246 $user_role->grantPermission('administer block types');
    247 $user_role->save();
    • Comment on lines 225 to +247

      This seems awkward... you'd probably not give this perm to that role on a real site... how about:

      How about

      Suggested change
      245 $user_role = \Drupal::entityTypeManager()->getStorage('user_role')->load(RoleInterface::AUTHENTICATED_ID);
      246 $user_role->grantPermission('administer block types');
      247 $user_role->save();
      245 \Drupal::service('module_installer')->install(['block_content']);
      246 $this->adminUser->addRole($this->drupalCreateRole(['administer block types']))->save();
      247 BlockContentType::create([
      248 'id' => 'basic',
      249 'label' => 'Basic block',
      250 'revision' => FALSE,
      251 ])->save();

      I'd also move after the module install so you make it relly obvious you can not do this earlier because the permission does not exist.

    • Pradhuman Jain changed this line in version 8 of the diff

      changed this line in version 8 of the diff

    • Please register or sign in to reply
  • Pradhuman Jain added 1 commit

    added 1 commit

    • 5a5aed5e - Issue #3439905: Made changes to install block content module and create user role.

    Compare with previous version

  • Soliman Harkas added 1 commit

    added 1 commit

    • f4b4255e - Issue #3439905: Refactor code to remove duplicates in shortcut links test

    Compare with previous version

  • Please register or sign in to reply
    Loading