1cce9898e8c6316a9193f71731309c2ca74ce856
[yaffs-website] / web / core / modules / file / tests / src / Unit / Plugin / migrate / process / d6 / CckFileTest.php
1 <?php
2
3 namespace Drupal\Tests\file\Unit\Plugin\migrate\process\d6;
4
5 use Drupal\file\Plugin\migrate\process\d6\CckFile;
6 use Drupal\migrate\Plugin\MigrationInterface;
7 use Drupal\migrate\MigrateExecutableInterface;
8 use Drupal\migrate\Plugin\MigrateProcessInterface;
9 use Drupal\migrate\Row;
10 use Drupal\Tests\UnitTestCase;
11
12 /**
13  * @group file
14  */
15 class CckFileTest extends UnitTestCase {
16
17   /**
18    * Tests that alt and title attributes are included in transformed values.
19    */
20   public function testTransformAltTitle() {
21     $executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
22     $row = $this->prophesize(Row::class)->reveal();
23     $migration = $this->prophesize(MigrationInterface::class)->reveal();
24
25     $migration_plugin = $this->prophesize(MigrateProcessInterface::class);
26     $migration_plugin->transform(1, $executable, $row, 'foo')->willReturn(1);
27
28     $plugin = new CckFile([], 'd6_cck_file', [], $migration, $migration_plugin->reveal());
29
30     $options = [
31       'alt' => 'Foobaz',
32       'title' => 'Wambooli',
33     ];
34     $value = [
35       'fid' => 1,
36       'list' => TRUE,
37       'data' => serialize($options),
38     ];
39
40     $transformed = $plugin->transform($value, $executable, $row, 'foo');
41     $expected = [
42       'target_id' => 1,
43       'display' => TRUE,
44       'description' => '',
45       'alt' => 'Foobaz',
46       'title' => 'Wambooli',
47     ];
48     $this->assertSame($expected, $transformed);
49   }
50
51 }