You are here

public function FieldDefaultTokenBasicTest::testReplacement in Field default token 8

Test that tokens in a field default value get replaced properly.

File

tests/src/Kernel/FieldDefaultTokenBasicTest.php, line 78

Class

FieldDefaultTokenBasicTest
Tests that tokens in field default values get replaced correctly.

Namespace

Drupal\Tests\field_default_token\Kernel

Code

public function testReplacement() {
  $field = $this
    ->createField();
  $field
    ->setDefaultValue('This is the site name: [site:name]')
    ->save();
  $entity = EntityTest::create();
  $entity
    ->save();
  $expected = [
    [
      'value' => 'This is the site name: ' . $this->siteName,
    ],
  ];
  $this
    ->assertEquals($expected, $field
    ->getDefaultValue($entity));
}