You are here

public function FieldDefaultTokenBasicTest::testCallbackRemoval in Field default token 8

Tests the the default value callback is removed properly.

File

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

Class

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

Namespace

Drupal\Tests\field_default_token\Kernel

Code

public function testCallbackRemoval() {
  $field = $this
    ->createField();
  $field
    ->setDefaultValue('This is the site name: [site:name]')
    ->save();
  $this
    ->assertEquals('field_default_token_default_value_callback', $field
    ->getDefaultValueCallback());
  $field
    ->setDefaultValue('There are no tokens to see here, move along')
    ->save();
  $this
    ->assertNull($field
    ->getDefaultValueCallback());
}