public function DateFieldTest::testDefineValueProcessPipeline in Drupal 10
Same name and namespace in other branches
- 8 core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php \Drupal\Tests\datetime\Unit\Plugin\migrate\field\DateFieldTest::testDefineValueProcessPipeline()
- 9 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 27
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) {
$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)
->will($this
->returnValue($migration));
$plugin = new DateField([], '', []);
$plugin
->defineValueProcessPipeline($migration, 'field_date', $data);
}