function StaticMapTest::testWithNullSourceWithEmptyStringMapping
Tests when the source is invalid but there's a mapping via an empty string.
Attributes
#[IgnoreDeprecations]
File
-
core/
modules/ migrate/ tests/ src/ Unit/ process/ StaticMapTest.php, line 109
Class
- StaticMapTest
- Tests the static map process plugin.
Namespace
Drupal\Tests\migrate\Unit\processCode
public function testWithNullSourceWithEmptyStringMapping() : void {
$configuration['map']['foo']['bar'] = 'baz';
$configuration['map'][''] = 'mapped NULL';
$this->plugin = new StaticMap($configuration, 'map', []);
$this->expectDeprecation('Relying on mapping NULL values via an empty string map key in Drupal\\migrate\\Plugin\\migrate\\process\\StaticMap::transform() is deprecated in drupal:11.3.0 and will trigger a Drupal\\migrate\\MigrateSkipRowException from drupal:12.0.0. Set the empty string map value as the "default_value" in the plugin configuration. See https://www.drupal.org/node/3557003');
$value = $this->plugin
->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
$this->assertSame('mapped NULL', $value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.