You are here

trait InstallTestTrait in Automatic Updates 8

Provides common functionality for automatic update test classes.

Hierarchy

2 files declare their use of InstallTestTrait
InPlaceUpdateTest.php in tests/src/Build/InPlaceUpdateTest.php
ModifiedFilesTest.php in tests/src/Build/ModifiedFilesTest.php

File

tests/src/Traits/InstallTestTrait.php, line 10

Namespace

Drupal\Tests\automatic_updates\Traits
View source
trait InstallTestTrait {

  /**
   * Helper method that uses Drupal's module page to install a module.
   */
  protected function moduleInstall($module_name) {
    $assert = $this
      ->visit('/admin/modules')
      ->assertSession();
    $field = Html::getClass("edit-modules {$module_name} enable");

    // No need to install a module if it is already install.
    if ($this
      ->getMink()
      ->getSession()
      ->getPage()
      ->findField($field)
      ->isChecked()) {
      return;
    }
    $assert
      ->fieldExists($field)
      ->check();
    $session = $this
      ->getMink()
      ->getSession();
    $session
      ->getPage()
      ->findButton('Install')
      ->submit();
    $assert
      ->fieldExists($field)
      ->isChecked();
    $assert
      ->statusCodeEquals(200);
  }

  /**
   * Helper method that uses Drupal's theme page to install a theme.
   */
  protected function themeInstall($theme_name) {
    $this
      ->moduleInstall('test_automatic_updates');
    $assert = $this
      ->visit("/admin/appearance/default?theme={$theme_name}")
      ->assertSession();
    $assert
      ->pageTextNotContains('theme was not found');
    $assert
      ->statusCodeEquals(200);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InstallTestTrait::moduleInstall protected function Helper method that uses Drupal's module page to install a module.
InstallTestTrait::themeInstall protected function Helper method that uses Drupal's theme page to install a theme.