You are here

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

@covers ::replacePlaceHolders

File

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

Class

PlaceholderResolverTest
Tests the placeholder resolver.

Namespace

Drupal\Tests\typed_data\Kernel

Code

public function testPlaceholdersAcrossReferences() {
  $user = $this->entityTypeManager
    ->getStorage('user')
    ->create([
    'name' => 'test',
    'type' => 'user',
  ]);
  $this->node->uid->entity = $user;
  $text = 'test {{node.title}} and {{node.uid.entity.name}}';
  $result = $this->placeholderResolver
    ->replacePlaceHolders($text, [
    'node' => $this->node
      ->getTypedData(),
  ]);
  $this
    ->assertEquals('test test and test', $result);
}