You are here

public function UrlTest::testCurrentRequestUrls in Token 8

Test the url token replacements for current requests.

The method ::expectedCurrentRequestUrlResults() is not declared as a regular data provider, because it might use services from the global Drupal container, which is not initialized yet during the invocation of data providers.

File

tests/src/Kernel/UrlTest.php, line 54

Class

UrlTest
Test generic url token replacements.

Namespace

Drupal\Tests\token\Kernel

Code

public function testCurrentRequestUrls() {
  foreach ($this
    ->expectedCurrentRequestUrlResults() as $data_set) {
    list($request, $text, $data, $options, $expected_output) = $data_set;

    // Set the request as the current one.
    $this->requestStack
      ->pop();
    $this->requestStack
      ->push($request);
    $this->currentRouteMatch
      ->resetRouteMatch();
    $this
      ->assertEquals($expected_output, $this->token
      ->replace($text, $data, $options));
  }
}