function BatchTestCallbacks::titleCallback

Tests the title on the progress page by performing a batch callback.

File

core/modules/system/tests/modules/batch_test/src/BatchTestCallbacks.php, line 37

Class

BatchTestCallbacks
Batch callbacks for testing batches.

Namespace

Drupal\batch_test

Code

public function titleCallback() : void {
  $batch_test_helper = new BatchTestHelper();
  // Because drupalGet() steps through the full progressive batch before
  // returning control to the test function, we cannot test that the correct
  // title is being used on the batch processing page by viewing that page
  // directly. Instead, we save the title being used in a variable here, so
  // that it can be loaded and inspected in the thread running the test.
  $request = \Drupal::request();
  $route_match = \Drupal::routeMatch();
  $title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
  $batch_test_helper->stack($title);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.