b20d3d0f41c9775600ce03c2118a1203e0f47e35
[yaffs-website] / web / core / modules / file / tests / src / Unit / Plugin / migrate / cckfield / d7 / ImageCckTest.php
1 <?php
2
3 namespace Drupal\Tests\file\Unit\Plugin\migrate\cckfield\d7;
4
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\Tests\UnitTestCase;
7 use Drupal\file\Plugin\migrate\cckfield\d7\ImageField;
8 use Prophecy\Argument;
9
10 /**
11  * @coversDefaultClass \Drupal\file\Plugin\migrate\cckfield\d7\ImageField
12  * @group file
13  * @group legacy
14  */
15 class ImageCckTest extends UnitTestCase {
16
17   /**
18    * @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
19    */
20   protected $plugin;
21
22   /**
23    * @var \Drupal\migrate\Plugin\MigrationInterface
24    */
25   protected $migration;
26
27   /**
28    * {@inheritdoc}
29    */
30   protected function setUp() {
31     $this->plugin = new ImageField([], 'image', []);
32
33     $migration = $this->prophesize(MigrationInterface::class);
34
35     // The plugin's defineValueProcessPipeline() method will call
36     // mergeProcessOfProperty() and return nothing. So, in order to examine the
37     // process pipeline created by the plugin, we need to ensure that
38     // getProcess() always returns the last input to mergeProcessOfProperty().
39     $migration->mergeProcessOfProperty(Argument::type('string'), Argument::type('array'))
40       ->will(function ($arguments) use ($migration) {
41         $migration->getProcess()->willReturn($arguments[1]);
42       });
43     $this->migration = $migration->reveal();
44   }
45
46   /**
47    * @covers ::processCckFieldValues
48    */
49   public function testProcessCckFieldValues() {
50     $this->plugin->processCckFieldValues($this->migration, 'somefieldname', []);
51
52     $expected = [
53       'plugin' => 'sub_process',
54       'source' => 'somefieldname',
55       'process' => [
56         'target_id' => 'fid',
57         'alt' => 'alt',
58         'title' => 'title',
59         'width' => 'width',
60         'height' => 'height',
61       ],
62     ];
63     $this->assertSame($expected, $this->migration->getProcess());
64   }
65
66 }