Verified Commit 0711d7f7 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439903 by pooja_sharma, SolimanHarkas, pradhumanjain2311, vensires,...

Issue #3439903 by pooja_sharma, SolimanHarkas, pradhumanjain2311, vensires, smustgrave: Fix Node tests that rely on UID1's super user behavior - Blocks
parent 15838422
Loading
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -28,14 +28,6 @@ class NodeAccessCacheabilityTest extends NodeTestBase {
    'node_access_test_auto_bubbling',
  ];

  /**
   * {@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;

  /**
   * {@inheritdoc}
   */
@@ -66,9 +58,9 @@ public function testNodeAccessCacheabilitySafeguard(): void {
    $this->drupalGet(new Url('node_access_test_auto_bubbling'));
    $this->assertCacheContext('user.node_grants:view');

    // The root user has the 'bypass node access' permission, which means the
    // The user has the 'bypass node access' permission, which means the
    // node grants cache context is not necessary.
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->drupalCreateUser(['bypass node access']));
    $this->drupalGet(new Url('node_access_test_auto_bubbling'));
    $this->assertNoCacheContext('user.node_grants:view');
    $this->drupalLogout();
+9 −9
Original line number Diff line number Diff line
@@ -22,14 +22,6 @@ class NodeAccessGrantsCacheContextTest extends NodeTestBase {
   */
  protected static $modules = ['node_access_test'];

  /**
   * {@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;

  /**
   * {@inheritdoc}
   */
@@ -52,6 +44,11 @@ class NodeAccessGrantsCacheContextTest extends NodeTestBase {
   */
  protected User $noAccessUser2;

  /**
   * User with permission to bypass node access.
   */
  protected $adminUser;

  /**
   * @var array
   */
@@ -86,9 +83,12 @@ protected function setUp(): void {
      'access content overview',
      'access content',
    ]);
    $this->adminUser = $this->drupalCreateUser([
      'bypass node access',
    ]);

    $this->userMapping = [
      1 => $this->rootUser,
      1 => $this->adminUser,
      2 => $this->accessUser,
      3 => $this->noAccessUser,
    ];
+5 −12
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User;
use Drupal\field\Entity\FieldStorageConfig;

/**
@@ -30,14 +29,6 @@ class NodeAccessLanguageAwareCombinationTest extends NodeAccessTestBase {
    'node_access_test',
  ];

  /**
   * {@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;

  /**
   * A set of nodes to use in testing.
   *
@@ -99,9 +90,11 @@ protected function setUp(): void {
    // Create a normal authenticated user.
    $this->webUser = $this->drupalCreateUser(['access content']);

    // Load the user 1 user for later use as an admin user with permission to
    // see everything.
    $this->adminUser = User::load(1);
    // Create a user as an admin user with permission bypass node access
    // to see everything.
    $this->adminUser = $this->drupalCreateUser([
      'bypass node access',
    ]);

    // The node_access_test_language module allows individual translations of a
    // node to be marked private (not viewable by normal users), and the
+5 −12
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\user\Entity\User;
use Drupal\field\Entity\FieldStorageConfig;

/**
@@ -25,14 +24,6 @@ class NodeAccessLanguageAwareTest extends NodeAccessTestBase {
   */
  protected static $modules = ['language', 'node_access_test_language'];

  /**
   * {@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;

  /**
   * A set of nodes to use in testing.
   *
@@ -88,9 +79,11 @@ protected function setUp(): void {
    // Create a normal authenticated user.
    $this->webUser = $this->drupalCreateUser(['access content']);

    // Load the user 1 user for later use as an admin user with permission to
    // see everything.
    $this->adminUser = User::load(1);
    // Create a user as an admin user with permission bypass node access
    // to see everything.
    $this->adminUser = $this->drupalCreateUser([
      'bypass node access',
    ]);

    // Add Hungarian and Catalan.
    ConfigurableLanguage::createFromLangcode('hu')->save();
+5 −12
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User;

/**
 * Tests multilingual node access with a module that is not language-aware.
@@ -22,14 +21,6 @@ class NodeAccessLanguageTest extends NodeAccessTestBase {
   */
  protected static $modules = ['language', 'node_access_test'];

  /**
   * {@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;

  /**
   * {@inheritdoc}
   */
@@ -193,9 +184,11 @@ public function testNodeAccessQueryTag(): void {
    // Create a normal authenticated user.
    $web_user = $this->drupalCreateUser(['access content']);

    // Load the user 1 user for later use as an admin user with permission to
    // see everything.
    $admin_user = User::load(1);
    // Create a user as an admin user with permission bypass node access
    // to see everything.
    $admin_user = $this->drupalCreateUser([
      'bypass node access',
    ]);

    // Creating a private node with langcode Hungarian, will be saved as
    // the fallback in node access table.
Loading