You are here

class ReadinessValidationTest in Automatic Updates 8.2

Tests readiness validation.

@group automatic_updates

Hierarchy

Expanded class hierarchy of ReadinessValidationTest

File

tests/src/Functional/ReadinessValidationTest.php, line 18

Namespace

Drupal\Tests\automatic_updates\Functional
View source
class ReadinessValidationTest extends AutomaticUpdatesFunctionalTestBase {
  use StringTranslationTrait;
  use CronRunTrait;
  use ValidationTestTrait;

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * A user who can view the status report.
   *
   * @var \Drupal\user\Entity\User
   */
  protected $reportViewerUser;

  /**
   * A user who can view the status report and run readiness checkers.
   *
   * @var \Drupal\user\Entity\User
   */
  protected $checkerRunnerUser;

  /**
   * The test checker.
   *
   * @var \Drupal\automatic_updates_test\ReadinessChecker\TestChecker1
   */
  protected $testChecker;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this
      ->setReleaseMetadata(__DIR__ . '/../../fixtures/release-history/drupal.9.8.1.xml');
    $this
      ->setCoreVersion('9.8.1');
    $this->reportViewerUser = $this
      ->createUser([
      'administer site configuration',
      'access administration pages',
    ]);
    $this->checkerRunnerUser = $this
      ->createUser([
      'administer site configuration',
      'administer software updates',
      'access administration pages',
    ]);
    $this
      ->createTestValidationResults();
    $this
      ->drupalLogin($this->reportViewerUser);
  }

  /**
   * Tests readiness checkers on status report page.
   */
  public function testReadinessChecksStatusReport() : void {
    $assert = $this
      ->assertSession();

    // Ensure automated_cron is disabled before installing automatic_updates. This
    // ensures we are testing that automatic_updates runs the checkers when the
    // module itself is installed and they weren't run on cron.
    $this
      ->assertFalse($this->container
      ->get('module_handler')
      ->moduleExists('automated_cron'));
    $this->container
      ->get('module_installer')
      ->install([
      'automatic_updates',
      'automatic_updates_test',
    ]);

    // If the site is ready for updates, the users will see the same output
    // regardless of whether the user has permission to run updates.
    $this
      ->drupalLogin($this->reportViewerUser);
    $this
      ->checkForUpdates();
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates.', 'checked', FALSE);
    $this
      ->drupalLogin($this->checkerRunnerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates. Run readiness checks now.', 'checked', FALSE);

    // Confirm a user without the permission to run readiness checks does not
    // have a link to run the checks when the checks need to be run again.
    // @todo Change this to fake the request time in
    //   https://www.drupal.org/node/3113971.

    /** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value */
    $key_value = $this->container
      ->get('keyvalue.expirable')
      ->get('automatic_updates');
    $key_value
      ->delete('readiness_validation_last_run');
    $this
      ->drupalLogin($this->reportViewerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates.', 'checked', FALSE);
    $this
      ->drupalLogin($this->checkerRunnerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates. Run readiness checks now.', 'checked', FALSE);

    // Confirm a user with the permission to run readiness checks does have a
    // link to run the checks when the checks need to be run again.
    $this
      ->drupalLogin($this->reportViewerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates.', 'checked', FALSE);
    $this
      ->drupalLogin($this->checkerRunnerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates. Run readiness checks now.', 'checked', FALSE);

    /** @var \Drupal\automatic_updates\Validation\ValidationResult[] $expected_results */
    $expected_results = $this->testResults['checker_1']['1 error'];
    TestChecker1::setTestResult($expected_results);

    // Run the readiness checks.
    $this
      ->clickLink('Run readiness checks');
    $assert
      ->statusCodeEquals(200);

    // Confirm redirect back to status report page.
    $assert
      ->addressEquals('/admin/reports/status');

    // Assert that when the runners are run manually the message that updates
    // will not be performed because of errors is displayed on the top of the
    // page in message.
    $assert
      ->pageTextMatchesCount(2, '/' . preg_quote(static::$errorsExplanation) . '/');
    $this
      ->assertReadinessReportMatches($expected_results[0]
      ->getMessages()[0] . 'Run readiness checks now.', 'error', static::$errorsExplanation);

    // @todo Should we always show when the checks were last run and a link to
    //   run when there is an error?
    // Confirm a user without permission to run the checks sees the same error.
    $this
      ->drupalLogin($this->reportViewerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches($expected_results[0]
      ->getMessages()[0], 'error', static::$errorsExplanation);
    $expected_results = $this->testResults['checker_1']['1 error 1 warning'];
    TestChecker1::setTestResult($expected_results);
    $key_value
      ->delete('readiness_validation_last_run');

    // Confirm a new message is displayed if the stored messages are deleted.
    $this
      ->drupalGet('admin/reports/status');

    // Confirm that on the status page if there is only 1 warning or error the
    // the summaries will not be displayed.
    $this
      ->assertReadinessReportMatches($expected_results['1:error']
      ->getMessages()[0], 'error', static::$errorsExplanation);
    $this
      ->assertReadinessReportMatches($expected_results['1:warning']
      ->getMessages()[0], 'warning', static::$warningsExplanation);
    $assert
      ->pageTextNotContains($expected_results['1:error']
      ->getSummary());
    $assert
      ->pageTextNotContains($expected_results['1:warning']
      ->getSummary());
    $key_value
      ->delete('readiness_validation_last_run');
    $expected_results = $this->testResults['checker_1']['2 errors 2 warnings'];
    TestChecker1::setTestResult($expected_results);
    $this
      ->drupalGet('admin/reports/status');

    // Confirm that both messages and summaries will be displayed on status
    // report when there multiple messages.
    $this
      ->assertReadinessReportMatches($expected_results['1:errors']
      ->getSummary() . ' ' . implode('', $expected_results['1:errors']
      ->getMessages()), 'error', static::$errorsExplanation);
    $this
      ->assertReadinessReportMatches($expected_results['1:warnings']
      ->getSummary() . ' ' . implode('', $expected_results['1:warnings']
      ->getMessages()), 'warning', static::$warningsExplanation);
    $key_value
      ->delete('readiness_validation_last_run');
    $expected_results = $this->testResults['checker_1']['2 warnings'];
    TestChecker1::setTestResult($expected_results);
    $this
      ->drupalGet('admin/reports/status');
    $assert
      ->pageTextContainsOnce('Update readiness checks');

    // Confirm that warnings will display on the status report if there are no
    // errors.
    $this
      ->assertReadinessReportMatches($expected_results[0]
      ->getSummary() . ' ' . implode('', $expected_results[0]
      ->getMessages()), 'warning', static::$warningsExplanation);
    $key_value
      ->delete('readiness_validation_last_run');
    $expected_results = $this->testResults['checker_1']['1 warning'];
    TestChecker1::setTestResult($expected_results);
    $this
      ->drupalGet('admin/reports/status');
    $assert
      ->pageTextContainsOnce('Update readiness checks');
    $this
      ->assertReadinessReportMatches($expected_results[0]
      ->getMessages()[0], 'warning', static::$warningsExplanation);
  }

  /**
   * Tests readiness checkers results on admin pages..
   */
  public function testReadinessChecksAdminPages() : void {
    $assert = $this
      ->assertSession();
    $messages_section_selector = '[data-drupal-messages]';

    // Ensure automated_cron is disabled before installing automatic_updates. This
    // ensures we are testing that automatic_updates runs the checkers when the
    // module itself is installed and they weren't run on cron.
    $this
      ->assertFalse($this->container
      ->get('module_handler')
      ->moduleExists('automated_cron'));
    $this->container
      ->get('module_installer')
      ->install([
      'automatic_updates',
      'automatic_updates_test',
    ]);

    // If site is ready for updates no message will be displayed on admin pages.
    $this
      ->drupalLogin($this->reportViewerUser);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates.', 'checked', FALSE);
    $this
      ->drupalGet('admin/structure');
    $assert
      ->elementNotExists('css', $messages_section_selector);

    // Confirm a user without the permission to run readiness checks does not
    // have a link to run the checks when the checks need to be run again.
    $expected_results = $this->testResults['checker_1']['1 error'];
    TestChecker1::setTestResult($expected_results);

    // @todo Change this to use ::delayRequestTime() to simulate running cron
    //   after a 24 wait instead of directly deleting 'readiness_validation_last_run'
    //   https://www.drupal.org/node/3113971.

    /** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $key_value */
    $key_value = $this->container
      ->get('keyvalue.expirable')
      ->get('automatic_updates');
    $key_value
      ->delete('readiness_validation_last_run');

    // A user without the permission to run the checkers will not see a message
    // on other pages if the checkers need to be run again.
    $this
      ->drupalGet('admin/structure');
    $assert
      ->elementNotExists('css', $messages_section_selector);

    // Confirm that a user with the correct permission can also run the checkers
    // on another admin page.
    $this
      ->drupalLogin($this->checkerRunnerUser);
    $this
      ->drupalGet('admin/structure');
    $assert
      ->elementExists('css', $messages_section_selector);
    $assert
      ->pageTextContainsOnce('Your site has not recently run an update readiness check. Run readiness checks now.');
    $this
      ->clickLink('Run readiness checks now.');
    $assert
      ->addressEquals('admin/structure');
    $assert
      ->pageTextContainsOnce($expected_results[0]
      ->getMessages()[0]);
    $expected_results = $this->testResults['checker_1']['1 error 1 warning'];
    TestChecker1::setTestResult($expected_results);

    // Confirm a new message is displayed if the cron is run after an hour.
    $this
      ->delayRequestTime();
    $this
      ->cronRun();
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextContainsOnce(static::$errorsExplanation);

    // Confirm on admin pages that a single error will be displayed instead of a
    // summary.
    $this
      ->assertSame(SystemManager::REQUIREMENT_ERROR, $expected_results['1:error']
      ->getSeverity());
    $assert
      ->pageTextContainsOnce($expected_results['1:error']
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results['1:error']
      ->getSummary());

    // Warnings are not displayed on admin pages if there are any errors.
    $this
      ->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results['1:warning']
      ->getSeverity());
    $assert
      ->pageTextNotContains($expected_results['1:warning']
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results['1:warning']
      ->getSummary());

    // Confirm that if cron runs less than hour after it previously ran it will
    // not run the checkers again.
    $unexpected_results = $this->testResults['checker_1']['2 errors 2 warnings'];
    TestChecker1::setTestResult($unexpected_results);
    $this
      ->delayRequestTime(30);
    $this
      ->cronRun();
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextNotContains($unexpected_results['1:errors']
      ->getSummary());
    $assert
      ->pageTextContainsOnce($expected_results['1:error']
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($unexpected_results['1:warnings']
      ->getSummary());
    $assert
      ->pageTextNotContains($expected_results['1:warning']
      ->getMessages()[0]);

    // Confirm that is if cron is run over an hour after the checkers were
    // previously run the checkers will be run again.
    $this
      ->delayRequestTime(31);
    $this
      ->cronRun();
    $expected_results = $unexpected_results;
    $this
      ->drupalGet('admin/structure');

    // Confirm on admin pages only the error summary will be displayed if there
    // is more than 1 error.
    $this
      ->assertSame(SystemManager::REQUIREMENT_ERROR, $expected_results['1:errors']
      ->getSeverity());
    $assert
      ->pageTextNotContains($expected_results['1:errors']
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results['1:errors']
      ->getMessages()[1]);
    $assert
      ->pageTextContainsOnce($expected_results['1:errors']
      ->getSummary());
    $assert
      ->pageTextContainsOnce(static::$errorsExplanation);

    // Warnings are not displayed on admin pages if there are any errors.
    $this
      ->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results['1:warnings']
      ->getSeverity());
    $assert
      ->pageTextNotContains($expected_results['1:warnings']
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results['1:warnings']
      ->getMessages()[1]);
    $assert
      ->pageTextNotContains($expected_results['1:warnings']
      ->getSummary());
    $expected_results = $this->testResults['checker_1']['2 warnings'];
    TestChecker1::setTestResult($expected_results);
    $this
      ->delayRequestTime();
    $this
      ->cronRun();
    $this
      ->drupalGet('admin/structure');

    // Confirm that the warnings summary is displayed on admin pages if there
    // are no errors.
    $assert
      ->pageTextNotContains(static::$errorsExplanation);
    $this
      ->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results[0]
      ->getSeverity());
    $assert
      ->pageTextNotContains($expected_results[0]
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results[0]
      ->getMessages()[1]);
    $assert
      ->pageTextContainsOnce(static::$warningsExplanation);
    $assert
      ->pageTextContainsOnce($expected_results[0]
      ->getSummary());
    $expected_results = $this->testResults['checker_1']['1 warning'];
    TestChecker1::setTestResult($expected_results);
    $this
      ->delayRequestTime();
    $this
      ->cronRun();
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextNotContains(static::$errorsExplanation);

    // Confirm that a single warning is displayed and not the summary on admin
    // pages if there is only 1 warning and there are no errors.
    $this
      ->assertSame(SystemManager::REQUIREMENT_WARNING, $expected_results[0]
      ->getSeverity());
    $assert
      ->pageTextContainsOnce(static::$warningsExplanation);
    $assert
      ->pageTextContainsOnce($expected_results[0]
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results[0]
      ->getSummary());
  }

  /**
   * Tests installing a module with a checker before installing automatic_updates.
   */
  public function testReadinessCheckAfterInstall() : void {
    $assert = $this
      ->assertSession();
    $this
      ->drupalLogin($this->checkerRunnerUser);
    $this
      ->drupalGet('admin/reports/status');
    $assert
      ->pageTextNotContains('Update readiness checks');

    // We have to install the automatic_updates_test module because it provides
    // the functionality to retrieve our fake release history metadata.
    $this->container
      ->get('module_installer')
      ->install([
      'automatic_updates',
      'automatic_updates_test',
    ]);
    $this
      ->drupalGet('admin/reports/status');
    $this
      ->assertReadinessReportMatches('Your site is ready for automatic updates. Run readiness checks now.', 'checked');
    $expected_results = $this->testResults['checker_1']['1 error'];
    TestChecker2::setTestResult($expected_results);
    $this->container
      ->get('module_installer')
      ->install([
      'automatic_updates_test2',
    ]);
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextContainsOnce($expected_results[0]
      ->getMessages()[0]);

    // Confirm that installing a module that does not provide a new checker does
    // not run the checkers on install.
    $unexpected_results = $this->testResults['checker_1']['2 errors 2 warnings'];
    TestChecker2::setTestResult($unexpected_results);
    $this->container
      ->get('module_installer')
      ->install([
      'help',
    ]);

    // Check for message on 'admin/structure' instead of the status report
    // because checkers will be run if needed on the status report.
    $this
      ->drupalGet('admin/structure');

    // Confirm that new checker message is not displayed because the checker was
    // not run again.
    $assert
      ->pageTextContainsOnce($expected_results[0]
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($unexpected_results['1:errors']
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($unexpected_results['1:errors']
      ->getSummary());
  }

  /**
   * Tests that checker message for an uninstalled module is not displayed.
   */
  public function testReadinessCheckerUninstall() : void {
    $assert = $this
      ->assertSession();
    $this
      ->drupalLogin($this->checkerRunnerUser);
    $expected_results_1 = $this->testResults['checker_1']['1 error'];
    TestChecker1::setTestResult($expected_results_1);
    $expected_results_2 = $this->testResults['checker_2']['1 error'];
    TestChecker2::setTestResult($expected_results_2);
    $this->container
      ->get('module_installer')
      ->install([
      'automatic_updates',
      'automatic_updates_test',
      'automatic_updates_test2',
    ]);

    // Check for message on 'admin/structure' instead of the status report
    // because checkers will be run if needed on the status report.
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextContainsOnce($expected_results_1[0]
      ->getMessages()[0]);
    $assert
      ->pageTextContainsOnce($expected_results_2[0]
      ->getMessages()[0]);

    // Confirm that when on of the module is uninstalled the other module's
    // checker result is still displayed.
    $this->container
      ->get('module_installer')
      ->uninstall([
      'automatic_updates_test2',
    ]);
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextNotContains($expected_results_2[0]
      ->getMessages()[0]);
    $assert
      ->pageTextContainsOnce($expected_results_1[0]
      ->getMessages()[0]);

    // Confirm that when on of the module is uninstalled the other module's
    // checker result is still displayed.
    $this->container
      ->get('module_installer')
      ->uninstall([
      'automatic_updates_test',
    ]);
    $this
      ->drupalGet('admin/structure');
    $assert
      ->pageTextNotContains($expected_results_2[0]
      ->getMessages()[0]);
    $assert
      ->pageTextNotContains($expected_results_1[0]
      ->getMessages()[0]);
  }

  /**
   * Asserts status report readiness report item matches a format.
   *
   * @param string $format
   *   The string to match.
   * @param string $section
   *   The section of the status report in which the string should appear.
   * @param string $message_prefix
   *   The prefix for before the string.
   */
  private function assertReadinessReportMatches(string $format, string $section = 'error', string $message_prefix = '') : void {
    $format = 'Update readiness checks ' . ($message_prefix ? "{$message_prefix} " : '') . $format;
    $text = $this
      ->getSession()
      ->getPage()
      ->find('css', "h3#{$section} ~ details.system-status-report__entry:contains('Update readiness checks')")
      ->getText();
    $this
      ->assertStringMatchesFormat($format, $text);
  }

  /**
   * Delays the request for the test.
   *
   * @param int $minutes
   *   The number of minutes to delay request time. Defaults to 61 minutes.
   */
  private function delayRequestTime(int $minutes = 61) : void {
    static $total_delay = 0;
    $total_delay += $minutes;
    TestTime::setFakeTimeByOffset("+{$total_delay} minutes");
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AssertHelperTrait::castSafeStrings protected static function Casts MarkupInterface objects into strings.
AssertLegacyTrait::assert protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::assertCacheTag protected function Asserts whether an expected cache tag was present in the last response.
AssertLegacyTrait::assertElementNotPresent protected function Asserts that the element with the given CSS selector is not present.
AssertLegacyTrait::assertElementPresent protected function Asserts that the element with the given CSS selector is present.
AssertLegacyTrait::assertEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertEscaped protected function Passes if the raw text IS found escaped on the loaded page, fail otherwise.
AssertLegacyTrait::assertField protected function Asserts that a field exists with the given name or ID.
AssertLegacyTrait::assertFieldById protected function Asserts that a field exists with the given ID and value.
AssertLegacyTrait::assertFieldByName protected function Asserts that a field exists with the given name and value.
AssertLegacyTrait::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
AssertLegacyTrait::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
AssertLegacyTrait::assertFieldsByValue protected function Asserts that a field exists in the current page with a given Xpath result.
AssertLegacyTrait::assertHeader protected function Checks that current response header equals value.
AssertLegacyTrait::assertIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertSame() instead.
AssertLegacyTrait::assertIdenticalObject protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertEquals() instead.
AssertLegacyTrait::assertLink protected function Passes if a link with the specified label is found.
AssertLegacyTrait::assertLinkByHref protected function Passes if a link containing a given href (part) is found.
AssertLegacyTrait::assertNoCacheTag protected function Asserts whether an expected cache tag was absent in the last response.
AssertLegacyTrait::assertNoEscaped protected function Passes if the raw text is not found escaped on the loaded page.
AssertLegacyTrait::assertNoField protected function Asserts that a field does NOT exist with the given name or ID.
AssertLegacyTrait::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
AssertLegacyTrait::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
AssertLegacyTrait::assertNoFieldByXPath protected function Asserts that a field does not exist or its value does not match, by XPath.
AssertLegacyTrait::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
AssertLegacyTrait::assertNoLink protected function Passes if a link with the specified label is not found.
AssertLegacyTrait::assertNoLinkByHref protected function Passes if a link containing a given href (part) is not found.
AssertLegacyTrait::assertNoOption protected function Asserts that a select option does NOT exist in the current page.
AssertLegacyTrait::assertNoPattern protected function Triggers a pass if the Perl regex pattern is not found in the raw content.
AssertLegacyTrait::assertNoRaw protected function Passes if the raw text IS not found on the loaded page, fail otherwise. 1
AssertLegacyTrait::assertNotEqual protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotEquals() instead.
AssertLegacyTrait::assertNoText protected function Passes if the page (with HTML stripped) does not contains the text. 1
AssertLegacyTrait::assertNotIdentical protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertNotSame() instead.
AssertLegacyTrait::assertNoUniqueText protected function Passes if the text is found MORE THAN ONCE on the text version of the page.
AssertLegacyTrait::assertOption protected function Asserts that a select option in the current page exists.
AssertLegacyTrait::assertOptionByText protected function Asserts that a select option with the visible text exists.
AssertLegacyTrait::assertOptionSelected protected function Asserts that a select option in the current page is checked.
AssertLegacyTrait::assertPattern protected function Triggers a pass if the Perl regex pattern is found in the raw content.
AssertLegacyTrait::assertRaw protected function Passes if the raw text IS found on the loaded page, fail otherwise. 1
AssertLegacyTrait::assertResponse protected function Asserts the page responds with the specified response code. 1
AssertLegacyTrait::assertText protected function Passes if the page (with HTML stripped) contains the text. 1
AssertLegacyTrait::assertTextHelper protected function Helper for assertText and assertNoText.
AssertLegacyTrait::assertTitle protected function Pass if the page title is the given string.
AssertLegacyTrait::assertUniqueText protected function Passes if the text is found ONLY ONCE on the text version of the page.
AssertLegacyTrait::assertUrl protected function Passes if the internal browser's URL matches the given path.
AssertLegacyTrait::buildXPathQuery protected function Builds an XPath query.
AssertLegacyTrait::constructFieldXpath protected function Helper: Constructs an XPath for the given set of attributes and value.
AssertLegacyTrait::getAllOptions protected function Get all option elements, including nested options, in a select.
AssertLegacyTrait::getRawContent protected function Gets the current raw content.
AssertLegacyTrait::pass protected function Deprecated Scheduled for removal in Drupal 10.0.0. Use self::assertTrue() instead.
AssertLegacyTrait::verbose protected function
AutomaticUpdatesFunctionalTestBase::$modules protected static property Modules to enable. Overrides BrowserTestBase::$modules 2
AutomaticUpdatesFunctionalTestBase::checkForUpdates protected function Checks for available updates.
AutomaticUpdatesFunctionalTestBase::prepareSettings protected function Prepares site settings and services before installation. Overrides FunctionalTestSetupTrait::prepareSettings
AutomaticUpdatesFunctionalTestBase::setCoreVersion protected function Sets the current (running) version of core, as known to the Update module.
AutomaticUpdatesFunctionalTestBase::setReleaseMetadata protected function Sets the release metadata file to use when fetching available updates.
BlockCreationTrait::placeBlock protected function Creates a block instance based on default settings. Aliased as: drupalPlaceBlock
BrowserHtmlDebugTrait::$htmlOutputBaseUrl protected property The Base URI to use for links to the output files.
BrowserHtmlDebugTrait::$htmlOutputClassName protected property Class name for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputCounter protected property Counter for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputCounterStorage protected property Counter storage for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputDirectory protected property Directory name for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputEnabled protected property HTML output output enabled.
BrowserHtmlDebugTrait::$htmlOutputFile protected property The file name to write the list of URLs to.
BrowserHtmlDebugTrait::$htmlOutputTestId protected property HTML output test ID.
BrowserHtmlDebugTrait::formatHtmlOutputHeaders protected function Formats HTTP headers as string for HTML output logging.
BrowserHtmlDebugTrait::getHtmlOutputHeaders protected function Returns headers in HTML output format. 1
BrowserHtmlDebugTrait::htmlOutput protected function Logs a HTML output message in a text file.
BrowserHtmlDebugTrait::initBrowserOutputFile protected function Creates the directory to store browser output.
BrowserTestBase::$baseUrl protected property The base URL.
BrowserTestBase::$configImporter protected property The config importer that can be used in a test.
BrowserTestBase::$customTranslations protected property An array of custom translations suitable for drupal_rewrite_settings().
BrowserTestBase::$databasePrefix protected property The database prefix of this test run.
BrowserTestBase::$mink protected property Mink session manager.
BrowserTestBase::$minkDefaultDriverArgs protected property
BrowserTestBase::$minkDefaultDriverClass protected property 1
BrowserTestBase::$originalContainer protected property The original container.
BrowserTestBase::$originalShutdownCallbacks protected property The original array of shutdown function callbacks.
BrowserTestBase::$preserveGlobalState protected property
BrowserTestBase::$profile protected property The profile to install as a basis for testing. 39
BrowserTestBase::$root protected property The app root.
BrowserTestBase::$runTestInSeparateProcess protected property Browser tests are run in separate processes to prevent collisions between code that may be loaded by tests.
BrowserTestBase::$timeLimit protected property Time limit in seconds for the test.
BrowserTestBase::$translationFilesDirectory protected property The translation file directory for the test environment.
BrowserTestBase::cleanupEnvironment protected function Clean up the Simpletest environment.
BrowserTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
BrowserTestBase::cssSelectToXpath protected function Translates a CSS expression to its XPath equivalent.
BrowserTestBase::drupalGetHeader protected function Gets the value of an HTTP response header.
BrowserTestBase::drupalGetHeaders Deprecated protected function Returns all response headers.
BrowserTestBase::filePreDeleteCallback public static function Ensures test files are deletable.
BrowserTestBase::getDefaultDriverInstance protected function Gets an instance of the default Mink driver.
BrowserTestBase::getDrupalSettings protected function Gets the JavaScript drupalSettings variable for the currently-loaded page. 1
BrowserTestBase::getHttpClient protected function Obtain the HTTP client for the system under test.
BrowserTestBase::getMinkDriverArgs protected function Get the Mink driver args from an environment variable, if it is set. Can be overridden in a derived class so it is possible to use a different value for a subset of tests, e.g. the JavaScript tests. 1
BrowserTestBase::getOptions protected function Helper function to get the options of select field.
BrowserTestBase::getResponseLogHandler protected function Provides a Guzzle middleware handler to log every response received. Overrides BrowserHtmlDebugTrait::getResponseLogHandler
BrowserTestBase::getSession public function Returns Mink session.
BrowserTestBase::getSessionCookies protected function Get session cookies from current session.
BrowserTestBase::getTestMethodCaller protected function Retrieves the current calling line in the class under test. Overrides BrowserHtmlDebugTrait::getTestMethodCaller
BrowserTestBase::initFrontPage protected function Visits the front page when initializing Mink. 3
BrowserTestBase::initMink protected function Initializes Mink sessions. 1
BrowserTestBase::installDrupal public function Installs Drupal into the Simpletest site. 1
BrowserTestBase::registerSessions protected function Registers additional Mink sessions.
BrowserTestBase::tearDown protected function 3
BrowserTestBase::translatePostValues protected function Transforms a nested array into a flat array suitable for drupalPostForm().
BrowserTestBase::xpath protected function Performs an xpath search on the contents of the internal browser.
BrowserTestBase::__construct public function 1
BrowserTestBase::__sleep public function Prevents serializing any properties.
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ContentTypeCreationTrait::createContentType protected function Creates a custom content type based on default settings. Aliased as: drupalCreateContentType 1
CronRunTrait::cronRun protected function Runs cron on the test site.
FunctionalTestSetupTrait::$apcuEnsureUniquePrefix protected property The flag to set 'apcu_ensure_unique_prefix' setting. 1
FunctionalTestSetupTrait::$classLoader protected property The class loader to use for installation and initialization of setup.
FunctionalTestSetupTrait::$configDirectories Deprecated protected property The config directories used in this test.
FunctionalTestSetupTrait::$rootUser protected property The "#1" admin user.
FunctionalTestSetupTrait::doInstall protected function Execute the non-interactive installer. 1
FunctionalTestSetupTrait::getDatabaseTypes protected function Returns all supported database driver installer objects.
FunctionalTestSetupTrait::initConfig protected function Initialize various configurations post-installation. 2
FunctionalTestSetupTrait::initKernel protected function Initializes the kernel after installation.
FunctionalTestSetupTrait::initSettings protected function Initialize settings created during install.
FunctionalTestSetupTrait::initUserSession protected function Initializes user 1 for the site to be installed.
FunctionalTestSetupTrait::installDefaultThemeFromClassProperty protected function Installs the default theme defined by `static::$defaultTheme` when needed.
FunctionalTestSetupTrait::installModulesFromClassProperty protected function Install modules defined by `static::$modules`. 1
FunctionalTestSetupTrait::installParameters protected function Returns the parameters that will be used when Simpletest installs Drupal. 9
FunctionalTestSetupTrait::prepareEnvironment protected function Prepares the current environment for running the test. 23
FunctionalTestSetupTrait::prepareRequestForGenerator protected function Creates a mock request and sets it on the generator.
FunctionalTestSetupTrait::rebuildAll protected function Resets and rebuilds the environment after setup.
FunctionalTestSetupTrait::rebuildContainer protected function Rebuilds \Drupal::getContainer().
FunctionalTestSetupTrait::resetAll protected function Resets all data structures after having enabled new modules.
FunctionalTestSetupTrait::setContainerParameter protected function Changes parameters in the services.yml file.
FunctionalTestSetupTrait::setupBaseUrl protected function Sets up the base URL based upon the environment variable.
FunctionalTestSetupTrait::writeSettings protected function Rewrites the settings.php file of the test site.
NodeCreationTrait::createNode protected function Creates a node based on default settings. Aliased as: drupalCreateNode
NodeCreationTrait::getNodeByTitle public function Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
RandomGeneratorTrait::$randomGenerator protected property The random generator.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers. 1
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RandomGeneratorTrait::randomStringValidate public function Callback for random string validation.
ReadinessValidationTest::$checkerRunnerUser protected property A user who can view the status report and run readiness checkers.
ReadinessValidationTest::$defaultTheme protected property The theme to install as the default for testing. Overrides BrowserTestBase::$defaultTheme
ReadinessValidationTest::$reportViewerUser protected property A user who can view the status report.
ReadinessValidationTest::$testChecker protected property The test checker.
ReadinessValidationTest::assertReadinessReportMatches private function Asserts status report readiness report item matches a format.
ReadinessValidationTest::delayRequestTime private function Delays the request for the test.
ReadinessValidationTest::setUp protected function Overrides BrowserTestBase::setUp
ReadinessValidationTest::testReadinessCheckAfterInstall public function Tests installing a module with a checker before installing automatic_updates.
ReadinessValidationTest::testReadinessCheckerUninstall public function Tests that checker message for an uninstalled module is not displayed.
ReadinessValidationTest::testReadinessChecksAdminPages public function Tests readiness checkers results on admin pages..
ReadinessValidationTest::testReadinessChecksStatusReport public function Tests readiness checkers on status report page.
RefreshVariablesTrait::refreshVariables protected function Refreshes in-memory configuration and state information. 3
SessionTestTrait::$sessionName protected property The name of the session cookie.
SessionTestTrait::generateSessionName protected function Generates a session cookie name.
SessionTestTrait::getSessionName protected function Returns the session name in use on the child site.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TestRequirementsTrait::checkModuleRequirements private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements protected function Check module requirements for the Drupal use case. 1
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
TestSetupTrait::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking.
TestSetupTrait::$container protected property The dependency injection container used in the test.
TestSetupTrait::$kernel protected property The DrupalKernel instance used in the test.
TestSetupTrait::$originalSite protected property The site directory of the original parent site.
TestSetupTrait::$privateFilesDirectory protected property The private file directory for the test environment.
TestSetupTrait::$publicFilesDirectory protected property The public file directory for the test environment.
TestSetupTrait::$siteDirectory protected property The site directory of this test run.
TestSetupTrait::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 2
TestSetupTrait::$tempFilesDirectory protected property The temporary file directory for the test environment.
TestSetupTrait::$testId protected property The test run ID.
TestSetupTrait::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
TestSetupTrait::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
TestSetupTrait::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
TestSetupTrait::prepareDatabasePrefix protected function Generates a database prefix for running tests. 2
UiHelperTrait::$loggedInUser protected property The current user logged in using the Mink controlled browser.
UiHelperTrait::$maximumMetaRefreshCount protected property The number of meta refresh redirects to follow, or NULL if unlimited.
UiHelperTrait::$metaRefreshCount protected property The number of meta refresh redirects followed during ::drupalGet().
UiHelperTrait::assertSession public function Returns WebAssert object. 1
UiHelperTrait::buildUrl protected function Builds an a absolute URL from a system path or a URL object.
UiHelperTrait::checkForMetaRefresh protected function Checks for meta refresh tag and if found call drupalGet() recursively.
UiHelperTrait::click protected function Clicks the element with the given CSS selector.
UiHelperTrait::clickLink protected function Follows a link by complete name.
UiHelperTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
UiHelperTrait::drupalGet protected function Retrieves a Drupal path or an absolute path. 3
UiHelperTrait::drupalLogin protected function Logs in a user using the Mink controlled browser.
UiHelperTrait::drupalLogout protected function Logs a user out of the Mink controlled browser and confirms.
UiHelperTrait::drupalPostForm protected function Executes a form submission.
UiHelperTrait::drupalUserIsLoggedIn protected function Returns whether a given user account is logged in.
UiHelperTrait::getAbsoluteUrl protected function Takes a path and returns an absolute path.
UiHelperTrait::getTextContent protected function Retrieves the plain-text content from the current page.
UiHelperTrait::getUrl protected function Get the current URL from the browser.
UiHelperTrait::prepareRequest protected function Prepare for a request to testing site. 1
UiHelperTrait::submitForm protected function Fills and submits a form.
UserCreationTrait::checkPermissions protected function Checks whether a given list of permission names is valid.
UserCreationTrait::createAdminRole protected function Creates an administrative role.
UserCreationTrait::createRole protected function Creates a role with specified permissions. Aliased as: drupalCreateRole
UserCreationTrait::createUser protected function Create a user with a given set of permissions. Aliased as: drupalCreateUser
UserCreationTrait::grantPermissions protected function Grant permissions to a user role.
UserCreationTrait::setCurrentUser protected function Switch the current logged in user.
UserCreationTrait::setUpCurrentUser protected function Creates a random user account and sets it as current user.
ValidationTestTrait::$errorsExplanation protected static property Expected explanation text when readiness checkers return error messages.
ValidationTestTrait::$testResults protected property Test validation results.
ValidationTestTrait::$warningsExplanation protected static property Expected explanation text when readiness checkers return warning messages.
ValidationTestTrait::assertCheckerResultsFromManager protected function Asserts expected validation results from the manager.
ValidationTestTrait::assertValidationResultsEqual protected function Asserts two validation result sets are equal.
ValidationTestTrait::createTestValidationResults protected function Creates ValidationResult objects to be used in tests.
ValidationTestTrait::getResultsFromManager protected function Gets the messages of a particular type from the manager.
XdebugRequestTrait::extractCookiesFromRequest protected function Adds xdebug cookies, from request setup.