function NullCoalesceTest::testTransformWithDefault

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Unit/process/NullCoalesceTest.php \Drupal\Tests\migrate\Unit\process\NullCoalesceTest::testTransformWithDefault()
  2. 10 core/modules/migrate/tests/src/Unit/process/NullCoalesceTest.php \Drupal\Tests\migrate\Unit\process\NullCoalesceTest::testTransformWithDefault()
  3. 11.x core/modules/migrate/tests/src/Unit/process/NullCoalesceTest.php \Drupal\Tests\migrate\Unit\process\NullCoalesceTest::testTransformWithDefault()

Tests null_coalesce with default value.

@covers ::transform

File

core/modules/migrate/tests/src/Unit/process/NullCoalesceTest.php, line 84

Class

NullCoalesceTest
Tests the null_coalesce process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testTransformWithDefault() {
  $plugin = new NullCoalesce([
    'default_value' => 'default',
  ], 'null_coalesce', []);
  $result = $plugin->transform([
    NULL,
    NULL,
    'Test',
    'Test 2',
  ], $this->migrateExecutable, $this->row, 'destination_property');
  $this->assertSame('Test', $result);
  $this->assertSame('default', $plugin->transform([
    NULL,
    NULL,
  ], $this->migrateExecutable, $this->row, 'destination_property'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.