Verified Commit 4ed57d45 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439907 by sukr_s, smustgrave, vensires, alexpott: Fix System tests...

Issue #3439907 by sukr_s, smustgrave, vensires, alexpott: Fix System tests that rely on UID1's super user behavior

(cherry picked from commit 8aeebfb3)
parent 0a15c5b8
Loading
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -22,14 +22,6 @@ class DrupalMessengerServiceTest extends BrowserTestBase {
   */
  protected static $modules = ['system_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}
   */
@@ -63,7 +55,8 @@ public function testDrupalMessengerService() {

    // Ensure messages survive a container rebuild.
    $assert = $this->assertSession();
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->drupalCreateUser(['administer modules']));

    $edit = [];
    $edit["modules[help][enable]"] = TRUE;
    $this->drupalGet('admin/modules');
+5 −9
Original line number Diff line number Diff line
@@ -23,14 +23,6 @@ class EntityReferenceFieldCreationTest extends BrowserTestBase {
   */
  protected static $modules = ['entity_test', 'node', 'field_ui'];

  /**
   * {@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}
   */
@@ -40,8 +32,12 @@ class EntityReferenceFieldCreationTest extends BrowserTestBase {
   * Tests that entity reference fields cannot target entity types without IDs.
   */
  public function testAddReferenceFieldTargetingEntityTypeWithoutId() {
    $this->drupalLogin($this->rootUser);

    $node_type = $this->drupalCreateContentType()->id();
    $this->drupalLogin($this->drupalCreateUser([
      'administer content types',
      'administer node fields',
    ]));

    // Entity types without an ID key should not be presented as options when
    // creating an entity reference field in the UI.
+2 −9
Original line number Diff line number Diff line
@@ -19,14 +19,6 @@ class FileSaveHtaccessLoggingTest extends BrowserTestBase {
   */
  protected static $modules = ['dblog'];

  /**
   * {@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}
   */
@@ -45,7 +37,8 @@ public function testHtaccessSave() {
    /** @var \Drupal\Core\File\HtaccessWriterInterface $htaccess */
    $htaccess = \Drupal::service('file.htaccess_writer');
    $this->assertFalse($htaccess->write($private, TRUE));
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->drupalCreateUser(['access site reports']));

    $this->drupalGet('admin/reports/dblog');
    $this->clickLink("Security warning: Couldn't write .htaccess file.");

+17 −9
Original line number Diff line number Diff line
@@ -24,14 +24,6 @@ class LocalTasksTest extends BrowserTestBase {
   */
  protected static $modules = ['block', 'menu_test', 'entity_test', 'node'];

  /**
   * {@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}
   */
@@ -268,11 +260,16 @@ public function testLocalTaskBlock() {
   * Tests that local tasks blocks cache is invalidated correctly.
   */
  public function testLocalTaskBlockCache() {
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->drupalCreateUser([
      'administer content types',
      'administer permissions',
    ]));
    $this->drupalCreateContentType(['type' => 'page']);

    // Only the Edit task. The block avoids showing a single tab.
    $this->drupalGet('/admin/config/people/accounts');
    // @@todo Add assertion here to check the page was actually visited.
    // https://www.drupal.org/project/drupal/issues/3443748
    $this->assertNoLocalTasks();

    // Only the Edit and Manage permission tabs.
@@ -284,6 +281,17 @@ public function testLocalTaskBlockCache() {

    // Field UI adds the usual Manage fields etc tabs.
    \Drupal::service('module_installer')->install(['field_ui']);

    $this->drupalLogin($this->drupalCreateUser([
      'administer content types',
      'administer permissions',
      'administer account settings',
      'administer display modes',
      'administer node display',
      'administer node fields',
      'administer node form display',
    ]));

    $this->drupalGet('/admin/structure/types/manage/page');
    $this->assertLocalTasks([
      ['entity.node_type.edit_form', ['node_type' => 'page']],
+5 −10
Original line number Diff line number Diff line
@@ -14,14 +14,6 @@
 */
class ClassLoaderTest extends BrowserTestBase {

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

  /**
   * The expected result from calling the module-provided class' method.
   *
@@ -97,7 +89,8 @@ public function testClassLoadingDisabledModules() {
   * Ensures the negative caches in the class loader don't result in crashes.
   */
  public function testMultipleModules() {
    $this->drupalLogin($this->rootUser);
    $this->drupalLogin($this->drupalCreateUser(['administer modules']));

    $edit = [
      "modules[module_install_class_loader_test1][enable]" => TRUE,
      "modules[module_install_class_loader_test2][enable]" => TRUE,
@@ -113,7 +106,9 @@ public function testMultipleModules() {
   */
  public function testAutoloadFromModuleFile() {
    $this->assertFalse(defined('MODULE_AUTOLOAD_TEST_CONSTANT'));
    $this->drupalLogin($this->rootUser);
    // Create use with required permissions.
    $this->drupalLogin($this->drupalCreateUser(['administer modules']));

    $edit = [
      "modules[module_autoload_test][enable]" => TRUE,
    ];
Loading