Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / migrate / tests / src / Kernel / Plugin / MigrationTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate\Kernel\Plugin;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests the migration plugin.
9  *
10  * @coversDefaultClass \Drupal\migrate\Plugin\Migration
11  * @group migrate
12  */
13 class MigrationTest extends KernelTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['migrate'];
19
20   /**
21    * Tests Migration::getProcessPlugins()
22    *
23    * @covers ::getProcessPlugins
24    */
25   public function testGetProcessPlugins() {
26     $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
27     $this->assertEquals([], $migration->getProcessPlugins([]));
28   }
29
30   /**
31    * Tests Migration::getMigrationDependencies()
32    *
33    * @covers ::getMigrationDependencies
34    */
35   public function testGetMigrationDependencies() {
36     $plugin_manager = \Drupal::service('plugin.manager.migration');
37     $plugin_definition = [
38       'process' => [
39         'f1' => 'bar',
40         'f2' => [
41           'plugin' => 'migration',
42           'migration' => 'm1'
43         ],
44         'f3' => [
45           'plugin' => 'sub_process',
46           'process' => [
47             'target_id' => [
48               'plugin' => 'migration',
49               'migration' => 'm2',
50             ],
51           ],
52         ],
53       ],
54     ];
55     $migration = $plugin_manager->createStubMigration($plugin_definition);
56     $this->assertSame(['required' => [], 'optional' => ['m1', 'm2']], $migration->getMigrationDependencies());
57   }
58
59   /**
60    * Tests Migration::getDestinationIds()
61    *
62    * @covers ::getDestinationIds
63    */
64   public function testGetDestinationIds() {
65     $migration = \Drupal::service('plugin.manager.migration')->createStubMigration(['destinationIds' => ['foo' => 'bar']]);
66     $destination_ids = $migration->getDestinationIds();
67     $this->assertNotEmpty($destination_ids, 'Destination ids are not empty');
68     $this->assertEquals(['foo' => 'bar'], $destination_ids, 'Destination ids match the expected values.');
69   }
70
71   /**
72    * Tests Migration::getTrackLastImported()
73    *
74    * @covers ::getTrackLastImported
75    * @covers ::isTrackLastImported
76    */
77   public function testGetTrackLastImported() {
78     $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
79     $migration->setTrackLastImported(TRUE);
80     $this->assertEquals(TRUE, $migration->getTrackLastImported());
81     $this->assertEquals(TRUE, $migration->isTrackLastImported());
82   }
83
84 }