3cf4031907387ff2536c041df636a2e89a4d645a
[yaffs-website] / web / core / modules / migrate_drupal / tests / src / Kernel / Plugin / migrate / source / d8 / ConfigTest.php
1 <?php
2
3 namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d8;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests the config source plugin.
9  *
10  * @covers \Drupal\migrate_drupal\Plugin\migrate\source\d8\Config
11  * @group migrate_drupal
12  */
13 class ConfigTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $data = [];
25
26     // The source database tables.
27     $data[0]['source_data'] = [
28       'config' => [
29         [
30           'collection' => 'language.af',
31           'name' => 'user.settings',
32           'data' => 'a:1:{s:9:"anonymous";s:14:"af - Anonymous";}',
33         ],
34         [
35           'collection' => '',
36           'name' => 'user.settings',
37           'data' => 'a:1:{s:9:"anonymous";s:9:"Anonymous";}',
38         ],
39         [
40           'collection' => 'language.de',
41           'name' => 'user.settings',
42           'data' => 'a:1:{s:9:"anonymous";s:14:"de - Anonymous";}',
43         ],
44         [
45           'collection' => 'language.af',
46           'name' => 'bar',
47           'data' => 'b:0;',
48         ],
49       ],
50     ];
51
52     // The expected results.
53     $data[0]['expected_results'] = [
54       [
55         'collection' => 'language.af',
56         'name' => 'user.settings',
57         'data' => [
58           'anonymous' => 'af - Anonymous',
59         ],
60       ],
61       [
62         'collection' => 'language.af',
63         'name' => 'bar',
64         'data' => FALSE,
65       ],
66     ];
67     $data[0]['expected_count'] = NULL;
68     $data[0]['configuration'] = [
69       'names' => [
70         'user.settings',
71         'bar',
72       ],
73       'collections' => [
74         'language.af',
75       ],
76     ];
77
78     // Test with name and no collection in configuration.
79     $data[1]['source_data'] = $data[0]['source_data'];
80     $data[1]['expected_results'] = [
81       [
82         'collection' => 'language.af',
83         'name' => 'bar',
84         'data' => FALSE,
85       ],
86     ];
87     $data[1]['expected_count'] = NULL;
88     $data[1]['configuration'] = [
89       'names' => [
90         'bar',
91       ],
92     ];
93
94     // Test with collection and no name in configuration.
95     $data[2]['source_data'] = $data[0]['source_data'];
96     $data[2]['expected_results'] = [
97       [
98         'collection' => 'language.de',
99         'name' => 'user.settings',
100         'data' => [
101           'anonymous' => 'de - Anonymous',
102         ],
103       ],
104     ];
105     $data[2]['expected_count'] = NULL;
106     $data[2]['configuration'] = [
107       'collections' => [
108         'language.de',
109       ],
110     ];
111
112     return $data;
113   }
114
115 }