You are here

public function UpdaterFormTest::testTableLooksCorrect in Automatic Updates 8.2

Tests that available updates are rendered correctly in a table.

@dataProvider providerTableLooksCorrect

Parameters

string $access_page: The page from which the update form should be visited. Can be one of 'modules' to visit via the module list, or 'reports' to visit via the administrative reports page.

File

tests/src/Functional/UpdaterFormTest.php, line 105

Class

UpdaterFormTest
@covers \Drupal\automatic_updates\Form\UpdaterForm

Namespace

Drupal\Tests\automatic_updates\Functional

Code

public function testTableLooksCorrect(string $access_page) : void {
  $this
    ->drupalPlaceBlock('local_tasks_block', [
    'primary' => TRUE,
  ]);
  $assert_session = $this
    ->assertSession();
  $this
    ->setCoreVersion('9.8.0');
  $this
    ->checkForUpdates();

  // Navigate to the automatic updates form.
  $this
    ->drupalGet('/admin');
  if ($access_page === 'modules') {
    $this
      ->clickLink('Extend');
    $assert_session
      ->pageTextContainsOnce('There is a security update available for your version of Drupal.');
  }
  else {
    $this
      ->clickLink('Reports');
    $assert_session
      ->pageTextContainsOnce('There is a security update available for your version of Drupal.');
    $this
      ->clickLink('Available updates');
  }
  $this
    ->clickLink('Update');
  $assert_session
    ->pageTextNotContains('There is a security update available for your version of Drupal.');
  $cells = $assert_session
    ->elementExists('css', '#edit-projects .update-update-security')
    ->findAll('css', 'td');
  $this
    ->assertCount(3, $cells);
  $assert_session
    ->elementExists('named', [
    'link',
    'Drupal',
  ], $cells[0]);
  $this
    ->assertSame('9.8.0', $cells[1]
    ->getText());
  $this
    ->assertSame('9.8.1 (Release notes)', $cells[2]
    ->getText());
  $release_notes = $assert_session
    ->elementExists('named', [
    'link',
    'Release notes',
  ], $cells[2]);
  $this
    ->assertSame('Release notes for Drupal', $release_notes
    ->getAttribute('title'));
  $assert_session
    ->buttonExists('Update');
}