Updated to Drupal 8.5. Core Media not yet in use.
[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  * @group legacy
15  */
16 class CckFileTest extends UnitTestCase {
17
18   /**
19    * Tests that alt and title attributes are included in transformed values.
20    *
21    * @expectedDeprecation CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.
22    */
23   public function testTransformAltTitle() {
24     $executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
25     $row = $this->prophesize(Row::class)->reveal();
26     $migration = $this->prophesize(MigrationInterface::class)->reveal();
27
28     $migration_plugin = $this->prophesize(MigrateProcessInterface::class);
29     $migration_plugin->transform(1, $executable, $row, 'foo')->willReturn(1);
30
31     $plugin = new CckFile([], 'd6_cck_file', [], $migration, $migration_plugin->reveal());
32
33     $options = [
34       'alt' => 'Foobaz',
35       'title' => 'Wambooli',
36     ];
37     $value = [
38       'fid' => 1,
39       'list' => TRUE,
40       'data' => serialize($options),
41     ];
42
43     $transformed = $plugin->transform($value, $executable, $row, 'foo');
44     $expected = [
45       'target_id' => 1,
46       'display' => TRUE,
47       'description' => '',
48       'alt' => 'Foobaz',
49       'title' => 'Wambooli',
50     ];
51     $this->assertSame($expected, $transformed);
52   }
53
54 }