You are here

protected function UpdateContribTest::assertCoreCompatibilityMessage in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::assertCoreCompatibilityMessage()
  2. 9 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::assertCoreCompatibilityMessage()

Asserts that a core compatibility message is correct for an update.

@internal

Parameters

string $version: The version of the update.

string $expected_range: The expected core compatibility range.

string $expected_release_title: The expected release title.

bool $is_compatible: If the update is compatible with the installed version of Drupal.

File

core/modules/update/tests/src/Functional/UpdateContribTest.php, line 872

Class

UpdateContribTest
Tests how the Update Manager module handles contributed modules and themes in a series of functional tests using mock XML data.

Namespace

Drupal\Tests\update\Functional

Code

protected function assertCoreCompatibilityMessage(string $version, string $expected_range, string $expected_release_title, bool $is_compatible = TRUE) : void {
  $update_element = $this
    ->findUpdateElementByLabel($expected_release_title);
  $this
    ->assertTrue($update_element
    ->hasLink($version));
  $compatibility_details = $update_element
    ->find('css', '.project-update__compatibility-details details');
  $this
    ->assertStringContainsString("Requires Drupal core: {$expected_range}", $compatibility_details
    ->getText());
  $details_summary_element = $compatibility_details
    ->find('css', 'summary');
  if ($is_compatible) {

    // If an update is compatible with the installed version of Drupal core,
    // the details element should be closed by default.
    $this
      ->assertFalse($compatibility_details
      ->hasAttribute('open'));
    $this
      ->assertSame('Compatible', $details_summary_element
      ->getText());
  }
  else {

    // If an update is not compatible with the installed version of Drupal
    // core, the details element should be open by default.
    $this
      ->assertTrue($compatibility_details
      ->hasAttribute('open'));
    $this
      ->assertSame('Not compatible', $details_summary_element
      ->getText());
  }
  $this
    ->assertFalse($update_element
    ->hasLink('Download'));
}