Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / link / tests / src / Unit / Plugin / migrate / field / d6 / LinkFieldTest.php
1 <?php
2
3 namespace Drupal\Tests\link\Unit\Plugin\migrate\field\d6;
4
5 use Drupal\migrate\Plugin\MigrationInterface;
6 use Drupal\Tests\UnitTestCase;
7 use Drupal\link\Plugin\migrate\field\d6\LinkField;
8 use Prophecy\Argument;
9
10 /**
11  * @coversDefaultClass \Drupal\link\Plugin\migrate\field\d6\LinkField
12  * @group link
13  */
14 class LinkFieldTest extends UnitTestCase {
15
16   /**
17    * @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
18    */
19   protected $plugin;
20
21   /**
22    * @var \Drupal\migrate\Plugin\MigrationInterface
23    */
24   protected $migration;
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUp() {
30     $this->plugin = new LinkField([], 'link', []);
31
32     $migration = $this->prophesize(MigrationInterface::class);
33
34     // The plugin's processFieldValues() method will call
35     // mergeProcessOfProperty() and return nothing. So, in order to examine the
36     // process pipeline created by the plugin, we need to ensure that
37     // getProcess() always returns the last input to mergeProcessOfProperty().
38     $migration->mergeProcessOfProperty(Argument::type('string'), Argument::type('array'))
39       ->will(function ($arguments) use ($migration) {
40         $migration->getProcess()->willReturn($arguments[1]);
41       });
42
43     $this->migration = $migration->reveal();
44   }
45
46   /**
47    * @covers ::processFieldValues
48    */
49   public function testProcessFieldValues() {
50     $this->plugin->processFieldValues($this->migration, 'somefieldname', []);
51
52     $expected = [
53       'plugin' => 'field_link',
54       'source' => 'somefieldname',
55     ];
56     $this->assertSame($expected, $this->migration->getProcess());
57   }
58
59 }