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