You are here

public function PlaceholderResolverTest::testStringEncoding in Typed Data API enhancements 8

@covers ::replacePlaceHolders

File

tests/src/Kernel/PlaceholderResolverTest.php, line 322

Class

PlaceholderResolverTest
Tests the placeholder resolver.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testStringEncoding() {
  $this->node->title->value = '<b>XSS</b>';
  $text = 'test {{node.title}}';
  $result = $this->placeholderResolver
    ->replacePlaceHolders($text, [
    'node' => $this->node
      ->getTypedData(),
  ]);
  $this
    ->assertEquals('test ' . new HtmlEscapedText('<b>XSS</b>'), $result);
}