You are here

protected function UpdateTestBase::waitForBatchJob in Automatic Updates 8.2

Waits for an active batch job to finish.

2 calls to UpdateTestBase::waitForBatchJob()
CoreUpdateTest::testUi in tests/src/Build/CoreUpdateTest.php
Tests an end-to-end core update via the UI.
UpdateTestBase::checkForUpdates in tests/src/Build/UpdateTestBase.php
Checks for available updates.

File

tests/src/Build/UpdateTestBase.php, line 300

Class

UpdateTestBase
Base class for tests that perform in-place updates.

Namespace

Drupal\Tests\automatic_updates\Build

Code

protected function waitForBatchJob() : void {
  $refresh = $this
    ->getMink()
    ->getSession()
    ->getPage()
    ->find('css', 'meta[http-equiv="Refresh"], meta[http-equiv="refresh"]');
  if ($refresh) {

    // Parse the content attribute of the meta tag for the format:
    // "[delay]: URL=[page_to_redirect_to]".
    if (preg_match('/\\d+;\\s*URL=\'?(?<url>[^\']*)/i', $refresh
      ->getAttribute('content'), $match)) {
      $url = Html::decodeEntities($match['url']);
      $this
        ->visit($url);
      $this
        ->waitForBatchJob();
    }
  }
}