function DateFieldTest::testDefineValueProcessPipeline
Same name in other branches
- 9 core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php \Drupal\Tests\datetime\Unit\Plugin\migrate\field\DateFieldTest::testDefineValueProcessPipeline()
- 8.9.x core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php \Drupal\Tests\datetime\Unit\Plugin\migrate\field\DateFieldTest::testDefineValueProcessPipeline()
- 11.x core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php \Drupal\Tests\datetime\Unit\Plugin\migrate\field\DateFieldTest::testDefineValueProcessPipeline()
Tests defineValueProcessPipeline.
@covers ::defineValueProcessPipeline
@dataProvider providerTestDefineValueProcessPipeline
File
-
core/
modules/ datetime/ tests/ src/ Unit/ Plugin/ migrate/ field/ DateFieldTest.php, line 29
Class
- DateFieldTest
- Provides unit tests for the DateField Plugin.
Namespace
Drupal\Tests\datetime\Unit\Plugin\migrate\fieldCode
public function testDefineValueProcessPipeline($data, $from_format, $to_format) : void {
$migration = $this->createMock('Drupal\\migrate\\Plugin\\MigrationInterface');
$pipeline = [
'plugin' => 'sub_process',
'source' => 'field_date',
'process' => [
'value' => [
'plugin' => 'format_date',
'from_format' => $from_format,
'to_format' => $to_format,
'source' => 'value',
],
],
];
// If there is a todate then add a process for the end value.
if (isset($data['field_definition']['data'])) {
$tmp = is_string($data['field_definition']['data']) ? unserialize($data['field_definition']['data']) : '';
$todate = $tmp['settings']['todate'] ?? NULL;
if (!empty($todate)) {
$pipeline['process']['end_value'] = [
'plugin' => 'format_date',
'from_format' => $from_format,
'to_format' => $to_format,
'source' => 'value2',
];
}
}
$migration->expects($this->once())
->method('mergeProcessOfProperty')
->with('field_date', $pipeline)
->willReturn($migration);
$plugin = new DateField([], '', []);
$plugin->defineValueProcessPipeline($migration, 'field_date', $data);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.