You are here

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

@covers ::replacePlaceHolders

File

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

Class

PlaceholderResolverTest
Tests the placeholder resolver.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testPlaceholdersWithMissingData() {
  $text = 'test {{node.title.1.value}}';
  $result = $this->placeholderResolver
    ->replacePlaceHolders($text, [
    'node' => $this->node
      ->getTypedData(),
  ], NULL, []);
  $this
    ->assertEquals('test {{node.title.1.value}}', $result);
  $result = $this->placeholderResolver
    ->replacePlaceHolders($text, [
    'node' => $this->node
      ->getTypedData(),
  ], NULL, [
    'clear' => FALSE,
  ]);
  $this
    ->assertEquals('test {{node.title.1.value}}', $result);
  $result = $this->placeholderResolver
    ->replacePlaceHolders($text, [
    'node' => $this->node
      ->getTypedData(),
  ], NULL, [
    'clear' => TRUE,
  ]);
  $this
    ->assertEquals('test ', $result);
}