3 namespace Drupal\Tests\file\Unit\Plugin\migrate\cckfield\d6;
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\migrate\Row;
7 use Drupal\Tests\UnitTestCase;
8 use Drupal\file\Plugin\migrate\cckfield\d6\FileField;
12 * @coversDefaultClass \Drupal\file\Plugin\migrate\cckfield\d6\FileField
16 class FileCckTest extends UnitTestCase {
19 * @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
24 * @var \Drupal\migrate\Plugin\MigrationInterface
31 protected function setUp() {
32 $this->plugin = new FileField([], 'file', []);
34 $migration = $this->prophesize(MigrationInterface::class);
36 // The plugin's processFieldValues() method will call
37 // mergeProcessOfProperty() and return nothing. So, in order to examine the
38 // process pipeline created by the plugin, we need to ensure that
39 // getProcess() always returns the last input to mergeProcessOfProperty().
40 $migration->mergeProcessOfProperty(Argument::type('string'), Argument::type('array'))
41 ->will(function ($arguments) use ($migration) {
42 $migration->getProcess()->willReturn($arguments[1]);
44 $this->migration = $migration->reveal();
48 * @covers ::processCckFieldValues
50 public function testProcessCckFieldValues() {
51 $this->plugin->processCckFieldValues($this->migration, 'somefieldname', []);
54 'plugin' => 'd6_cck_file',
55 'source' => 'somefieldname',
57 $this->assertSame($expected, $this->migration->getProcess());
61 * Data provider for testGetFieldType().
63 public function getFieldTypeProvider() {
65 ['image', 'imagefield_widget'],
66 ['file', 'filefield_widget'],
72 * @covers ::getFieldType
73 * @dataProvider getFieldTypeProvider
75 public function testGetFieldType($expected_type, $widget_type, array $settings = []) {
77 $row->setSourceProperty('widget_type', $widget_type);
78 $row->setSourceProperty('global_settings', $settings);
79 $this->assertSame($expected_type, $this->plugin->getFieldType($row));