Verified Commit 510a7a22 authored by godotislate's avatar godotislate
Browse files

task: #3614518 Remove unnecessary requests and consolidate test methods in ConfigInstallWebTest

By: catch
By: smustgrave
By: mstrelan
By: godotislate
parent 7156a086
Loading
Loading
Loading
Loading
+12 −14
Changes for core/modules/config/tests/src/Functional/ConfigInstallWebTest.php: 12 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -162,7 +162,6 @@ public function testPreExistingConfigInstall(): void {
    // The user is shown a confirm form because the config_test module is a
    // dependency.
    // @see \Drupal\system\Form\ModulesListConfirmForm::submitForm()
    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_install_fail_test][enable]' => TRUE], 'Install');
    $this->submitForm([], 'Continue');
    // @todo improve error message as the config does not exist. But both modules
@@ -172,7 +171,6 @@ public function testPreExistingConfigInstall(): void {

    // Install the config test module so that the configuration does actually
    // exist.
    $this->drupalGet('admin/modules');
    $this->submitForm([
      'modules[config_test][enable]' => TRUE,
    ], 'Install');
@@ -216,28 +214,32 @@ public function testPreExistingConfigInstall(): void {
    }
  }

  /**
   * Tests various config install scenarios.
   */
  public function testConfigInstall(): void {
    $this->doTestUnmetDependenciesInstall();
    $this->doTestConfigModuleRequirements();
    $this->doTestEnumsAndConstantsInModules();
  }

  /**
   * Tests unmet dependencies detection.
   */
  public function testUnmetDependenciesInstall(): void {
  protected function doTestUnmetDependenciesInstall(): void {
    $this->drupalLogin($this->adminUser);
    // We need to install separately since config_install_dependency_test does
    // not depend on config_test and order is important.
    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_test][enable]' => TRUE], 'Install');
    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_install_dependency_test][enable]' => TRUE], 'Install');
    $this->assertSession()->responseContains('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');

    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_test_language][enable]' => TRUE], 'Install');
    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_install_dependency_test][enable]' => TRUE], 'Install');
    $this->assertSession()->responseContains('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');

    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_other_module_config_test][enable]' => TRUE], 'Install');
    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config_install_dependency_test][enable]' => TRUE], 'Install');
    $this->rebuildContainer();
    $this->assertInstanceOf(ConfigTest::class, \Drupal::entityTypeManager()->getStorage('config_test')->load('other_module_test_with_dependency'));
@@ -246,8 +248,7 @@ public function testUnmetDependenciesInstall(): void {
  /**
   * Tests config_requirements().
   */
  public function testConfigModuleRequirements(): void {
    $this->drupalLogin($this->adminUser);
  protected function doTestConfigModuleRequirements(): void {
    $this->drupalGet('admin/modules');
    $this->submitForm(['modules[config][enable]' => TRUE], 'Install');

@@ -265,8 +266,7 @@ public function testConfigModuleRequirements(): void {
  /**
   * Tests installing modules with enums and constants in config.
   */
  public function testEnumsAndConstantsInModules(): void {
    $this->drupalLogin($this->adminUser);
  protected function doTestEnumsAndConstantsInModules(): void {
    $this->drupalGet('admin/modules');

    // Install modules using enums at the same time. This ensures that a module
@@ -282,8 +282,6 @@ public function testEnumsAndConstantsInModules(): void {
    $this->assertSame(AnotherEnumValue::Foo, $this->config('config_enum_dependency_test.settings')->get('status'));
    $this->assertSame(EnumValue::Maybe, $this->config('config_enum_test.settings')->get('foo'));

    $this->drupalGet('admin/modules');

    // Enable a module which has a constant in configuration.
    $this->assertSession()->fieldExists('edit-modules-config-constant-test-enable')->check();
    $this->submitForm([], 'Install');