Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / migrate / tests / src / Kernel / Plugin / MigrationPluginConfigurationTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate\Kernel\Plugin;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests the migration plugin manager.
9  *
10  * @coversDefaultClass \Drupal\migrate\Plugin\MigratePluginManager
11  * @group migrate
12  */
13 class MigrationPluginConfigurationTest extends KernelTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = [
19     'migrate',
20     'migrate_drupal',
21     // Test with a simple migration.
22     'ban',
23   ];
24
25   /**
26    * Test merging configuration into a plugin through the plugin manager.
27    *
28    * @dataProvider mergeProvider
29    */
30   public function testConfigurationMerge($configuration, $expected) {
31     /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
32     $migration = $this->container->get('plugin.manager.migration')->createInstance('d7_blocked_ips', $configuration);
33     $source_configuration = $migration->getSourceConfiguration();
34     $this->assertEquals($expected, $source_configuration);
35   }
36
37   /**
38    * Provide configuration data for testing.
39    */
40   public function mergeProvider() {
41     return [
42       // Tests adding new configuration to a migration.
43       [
44         // New configuration.
45         [
46           'source' => [
47             'constants' => [
48               'added_setting' => 'Ban them all!',
49             ],
50           ],
51         ],
52         // Expected final source configuration.
53         [
54           'plugin' => 'd7_blocked_ips',
55           'constants' => [
56             'added_setting' => 'Ban them all!',
57           ],
58         ],
59       ],
60       // Tests overriding pre-existing configuration in a migration.
61       [
62         // New configuration.
63         [
64           'source' => [
65             'plugin' => 'a_different_plugin',
66           ],
67         ],
68         // Expected final source configuration.
69         [
70           'plugin' => 'a_different_plugin',
71         ],
72       ],
73     ];
74   }
75
76 }