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