Skip to content
Snippets Groups Projects
Commit 46b8545d authored by catch's avatar catch
Browse files

Issue #3439905 by SolimanHarkas, thebumik, smustgrave, pradhumanjain2311,...

Issue #3439905 by SolimanHarkas, thebumik, smustgrave, pradhumanjain2311, vensires, alexpott: Fix Shortcut tests that rely on UID1's super user behavior
parent f45c7bd1
No related branches found
No related tags found
29 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3478Issue #3337882: Deleted menus are not removed from content type config,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #151306 canceled
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
use Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase; use Drupal\Tests\system\Functional\Entity\EntityCacheTagsTestBase;
use Drupal\user\Entity\Role; use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface; use Drupal\user\RoleInterface;
use Drupal\user\UserInterface;
/** /**
* Tests the Shortcut entity's cache tags. * Tests the Shortcut entity's cache tags.
...@@ -32,12 +33,11 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase { ...@@ -32,12 +33,11 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase {
]; ];
/** /**
* {@inheritdoc} * User with permission to administer shortcuts.
* *
* @todo Remove and fix test to not rely on super user. * @var \Drupal\user\UserInterface
* @see https://www.drupal.org/project/drupal/issues/3437620
*/ */
protected bool $usesSuperUserAccessPolicy = TRUE; protected UserInterface $adminUser;
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -50,6 +50,14 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase { ...@@ -50,6 +50,14 @@ class ShortcutCacheTagsTest extends EntityCacheTagsTestBase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->adminUser = $this->drupalCreateUser([
'access toolbar',
'access shortcuts',
'administer site configuration',
'administer shortcuts',
'administer themes',
]);
// Give anonymous users permission to customize shortcut links, so that we // Give anonymous users permission to customize shortcut links, so that we
// can verify the cache tags of cached versions of shortcuts. // can verify the cache tags of cached versions of shortcuts.
$user_role = Role::load(RoleInterface::ANONYMOUS_ID); $user_role = Role::load(RoleInterface::ANONYMOUS_ID);
...@@ -109,7 +117,7 @@ public function testToolbar() { ...@@ -109,7 +117,7 @@ public function testToolbar() {
// Ensure that without enabling the shortcuts-in-page-title-link feature // Ensure that without enabling the shortcuts-in-page-title-link feature
// in the theme, the shortcut_list cache tag is not added to the page. // in the theme, the shortcut_list cache tag is not added to the page.
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/system/cron'); $this->drupalGet('admin/config/system/cron');
$expected_cache_tags = [ $expected_cache_tags = [
'block_view', 'block_view',
...@@ -286,7 +294,7 @@ public function testBlock(): void { ...@@ -286,7 +294,7 @@ public function testBlock(): void {
// Ensure that without enabling the shortcuts-in-page-title-link feature // Ensure that without enabling the shortcuts-in-page-title-link feature
// in the theme, the shortcut_list cache tag is not added to the page. // in the theme, the shortcut_list cache tag is not added to the page.
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/system/cron'); $this->drupalGet('admin/config/system/cron');
$expected_cache_tags = [ $expected_cache_tags = [
'CACHE_MISS_IF_UNCACHEABLE_HTTP_METHOD:form', 'CACHE_MISS_IF_UNCACHEABLE_HTTP_METHOD:form',
......
...@@ -33,11 +33,8 @@ class ShortcutLinksTest extends ShortcutTestBase { ...@@ -33,11 +33,8 @@ class ShortcutLinksTest extends ShortcutTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*
* @todo Remove and fix test to not rely on super user.
* @see https://www.drupal.org/project/drupal/issues/3437620
*/ */
protected bool $usesSuperUserAccessPolicy = TRUE; protected $adminUser;
/** /**
* {@inheritdoc} * {@inheritdoc}
...@@ -50,6 +47,22 @@ class ShortcutLinksTest extends ShortcutTestBase { ...@@ -50,6 +47,22 @@ class ShortcutLinksTest extends ShortcutTestBase {
protected function setUp(): void { protected function setUp(): void {
parent::setUp(); parent::setUp();
$this->adminUser = $this->drupalCreateUser([
'access toolbar',
'administer shortcuts',
'view the administration theme',
'access content overview',
'administer users',
'administer site configuration',
'administer content types',
'create article content',
'create page content',
'edit any article content',
'edit any page content',
'administer blocks',
'access shortcuts',
]);
$this->drupalPlaceBlock('page_title_block'); $this->drupalPlaceBlock('page_title_block');
} }
...@@ -164,7 +177,7 @@ public function testShortcutQuickLink() { ...@@ -164,7 +177,7 @@ public function testShortcutQuickLink() {
$this->config('node.settings')->set('use_admin_theme', '1')->save(); $this->config('node.settings')->set('use_admin_theme', '1')->save();
$this->container->get('router.builder')->rebuild(); $this->container->get('router.builder')->rebuild();
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/system/cron'); $this->drupalGet('admin/config/system/cron');
// Test the "Add to shortcuts" link. // Test the "Add to shortcuts" link.
...@@ -221,8 +234,8 @@ public function testShortcutQuickLink() { ...@@ -221,8 +234,8 @@ public function testShortcutQuickLink() {
$this->clickLink('Remove from Default shortcuts'); $this->clickLink('Remove from Default shortcuts');
$this->assertSession()->pageTextContains("The shortcut $title has been deleted."); $this->assertSession()->pageTextContains("The shortcut $title has been deleted.");
$this->assertShortcutQuickLink('Add to Default shortcuts'); $this->assertShortcutQuickLink('Add to Default shortcuts');
\Drupal::service('module_installer')->install(['block_content']); \Drupal::service('module_installer')->install(['block_content']);
$this->adminUser->addRole($this->drupalCreateRole(['administer block types']))->save();
BlockContentType::create([ BlockContentType::create([
'id' => 'basic', 'id' => 'basic',
'label' => 'Basic block', 'label' => 'Basic block',
...@@ -284,7 +297,7 @@ public function testShortcutLinkChangePath() { ...@@ -284,7 +297,7 @@ public function testShortcutLinkChangePath() {
* Tests that changing the route of a shortcut link works. * Tests that changing the route of a shortcut link works.
*/ */
public function testShortcutLinkChangeRoute() { public function testShortcutLinkChangeRoute() {
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/content'); $this->drupalGet('admin/content');
$this->assertSession()->statusCodeEquals(200); $this->assertSession()->statusCodeEquals(200);
// Disable the view. // Disable the view.
...@@ -360,7 +373,7 @@ public function testAccessShortcutsPermission() { ...@@ -360,7 +373,7 @@ public function testAccessShortcutsPermission() {
->save(); ->save();
// Add cron to the default shortcut set. // Add cron to the default shortcut set.
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/config/system/cron'); $this->drupalGet('admin/config/system/cron');
$this->clickLink('Add to Default shortcuts'); $this->clickLink('Add to Default shortcuts');
......
  • catch @catch

    mentioned in commit 11edb986

    ·

    mentioned in commit 11edb986

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment