3 namespace Drupal\Tests\file\Unit\Plugin\migrate\field\d7;
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\Tests\UnitTestCase;
7 use Drupal\file\Plugin\migrate\field\d7\ImageField;
11 * @coversDefaultClass \Drupal\file\Plugin\migrate\field\d7\ImageField
14 class ImageFieldTest extends UnitTestCase {
17 * @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
22 * @var \Drupal\migrate\Plugin\MigrationInterface
29 protected function setUp() {
30 $this->plugin = new ImageField([], 'image', []);
32 $migration = $this->prophesize(MigrationInterface::class);
34 // The plugin's processFieldValues() method will call
35 // mergeProcessOfProperty() and return nothing. So, in order to examine the
36 // process pipeline created by the plugin, we need to ensure that
37 // getProcess() always returns the last input to mergeProcessOfProperty().
38 $migration->mergeProcessOfProperty(Argument::type('string'), Argument::type('array'))
39 ->will(function ($arguments) use ($migration) {
40 $migration->getProcess()->willReturn($arguments[1]);
42 $this->migration = $migration->reveal();
46 * @covers ::processFieldValues
48 public function testProcessFieldValues() {
49 $this->plugin->processFieldValues($this->migration, 'somefieldname', []);
52 'plugin' => 'sub_process',
53 'source' => 'somefieldname',
62 $this->assertSame($expected, $this->migration->getProcess());