Issue #3439905: Fix shortcut tests
5 unresolved threads
5 unresolved threads
Closes #3439905
Merge request reports
Activity
added 1 commit
228 245 'label' => 'Basic block', 229 246 'revision' => FALSE, 230 247 ])->save(); 248 $user_role = Role::load(RoleInterface::AUTHENTICATED_ID); Are we sure we want direct Role::load() instead of
\Drupal::entityTypeManager()->getStorage('user_role')->load()
here? I find it safe as it is but I thought better to consider it before setting it as RTBC.Edited by Panagiotis Moutsopouloschanged this line in version 5 of the diff
29 29 'shortcut', 30 30 'test_page_test', 31 31 'block', 32 'node', changed this line in version 5 of the diff
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; changed this line in version 5 of the diff
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; changed this line in version 6 of the diff
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
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.
changed this line in version 8 of the diff
added 1 commit
added 1 commit
Please register or sign in to reply