d1e55d10a4b184b226e5aa278441d64de4e65934
[yaffs-website] / web / core / modules / link / tests / src / Kernel / Plugin / migrate / cckfield / d7 / LinkCckTest.php
1 <?php
2
3 namespace Drupal\Tests\link\Kernel\Plugin\migrate\cckfield\d7;
4
5 use Drupal\KernelTests\KernelTestBase;
6 use Drupal\migrate\Plugin\MigrationInterface;
7 use Drupal\link\Plugin\migrate\cckfield\d7\LinkField;
8 use Prophecy\Argument;
9
10 /**
11  * @coversDefaultClass \Drupal\link\Plugin\migrate\cckfield\d7\LinkField
12  * @group link
13  * @group legacy
14  */
15 class LinkCckTest extends KernelTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected static $modules = ['system'];
21
22   /**
23    * @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
24    */
25   protected $plugin;
26
27   /**
28    * @var \Drupal\migrate\Plugin\MigrationInterface
29    */
30   protected $migration;
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function setUp() {
36     parent::setUp();
37
38     $this->plugin = new LinkField([], 'link', []);
39
40     $migration = $this->prophesize(MigrationInterface::class);
41
42     // The plugin's alterFieldInstanceMigration() method will call
43     // mergeProcessOfProperty() and return nothing. So, in order to examine the
44     // process pipeline created by the plugin, we need to ensure that
45     // getProcess() always returns the last input to mergeProcessOfProperty().
46     $migration->mergeProcessOfProperty(Argument::type('string'), Argument::type('array'))
47       ->will(function ($arguments) use ($migration) {
48         $migration->getProcess()->willReturn($arguments[1]);
49       });
50
51     $this->migration = $migration->reveal();
52   }
53
54   /**
55    * @covers ::alterFieldInstanceMigration
56    */
57   public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') {
58     $this->plugin->$method($this->migration);
59
60     $expected = [
61       'plugin' => 'static_map',
62       'source' => 'settings/title',
63       'bypass' => TRUE,
64       'map' => [
65         'disabled' => DRUPAL_DISABLED,
66         'optional' => DRUPAL_OPTIONAL,
67         'required' => DRUPAL_REQUIRED,
68       ],
69     ];
70     $this->assertSame($expected, $this->migration->getProcess());
71   }
72
73 }