You are here

public function DefaultValueTest::testOnlyIfEmptyToDefaultValue in Tamper 8

Test only empty value changed to the default value.

File

tests/src/Unit/Plugin/Tamper/DefaultValueTest.php, line 44

Class

DefaultValueTest
Tests the default value plugin.

Namespace

Drupal\Tests\tamper\Unit\Plugin\Tamper

Code

public function testOnlyIfEmptyToDefaultValue() {
  $config = [
    DefaultValue::SETTING_DEFAULT_VALUE => 'HEYO!',
    DefaultValue::SETTING_ONLY_IF_EMPTY => TRUE,
  ];
  $plugin = new DefaultValue($config, 'default_value', [], $this
    ->getMockSourceDefinition());
  $this
    ->assertEquals('HEYO!', $plugin
    ->tamper([]));
  $this
    ->assertEquals([
    1,
  ], $plugin
    ->tamper([
    1,
  ]));
}