function TokenTest::testReplaceEscaping

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::testReplaceEscaping()
  2. 8.9.x core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::testReplaceEscaping()
  3. 11.x core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::testReplaceEscaping()

@covers ::replace
@dataProvider providerTestReplaceEscaping

File

core/tests/Drupal/Tests/Core/Utility/TokenTest.php, line 270

Class

TokenTest
@coversDefaultClass \Drupal\Core\Utility\Token[[api-linebreak]] @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

public function testReplaceEscaping($string, array $tokens, $expected) : void {
  $this->moduleHandler
    ->expects($this->any())
    ->method('invokeAll')
    ->willReturnCallback(function ($type, $args) {
    return $args[2]['tokens'];
  });
  $result = $this->token
    ->replace($string, [
    'tokens' => $tokens,
  ]);
  $this->assertIsString($result);
  $this->assertEquals($expected, $result);
}

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