function StaticMapTest::testMapWithInvalidSourceWithADefaultValue

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Unit/process/StaticMapTest.php \Drupal\Tests\migrate\Unit\process\StaticMapTest::testMapWithInvalidSourceWithADefaultValue()
  2. 10 core/modules/migrate/tests/src/Unit/process/StaticMapTest.php \Drupal\Tests\migrate\Unit\process\StaticMapTest::testMapWithInvalidSourceWithADefaultValue()
  3. 11.x core/modules/migrate/tests/src/Unit/process/StaticMapTest.php \Drupal\Tests\migrate\Unit\process\StaticMapTest::testMapWithInvalidSourceWithADefaultValue()

Tests when the source is invalid but there's a default.

File

core/modules/migrate/tests/src/Unit/process/StaticMapTest.php, line 62

Class

StaticMapTest
Tests the static map process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testMapWithInvalidSourceWithADefaultValue() {
    $configuration['map']['foo']['bar'] = 'baz';
    $configuration['default_value'] = 'test';
    $this->plugin = new StaticMap($configuration, 'map', []);
    $value = $this->plugin
        ->transform([
        'bar',
    ], $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame('test', $value);
}

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