Version 1
[yaffs-website] / web / core / modules / user / tests / src / Kernel / Plugin / migrate / source / d7 / UserTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d7;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests the d7_user source plugin.
9  *
10  * @covers \Drupal\user\Plugin\migrate\source\d7\User
11  * @group user
12  */
13 class UserTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['user', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $tests = [];
25
26     // The source data.
27     $tests[0]['source_data']['field_config_instance'] = [
28       [
29         'id' => '33',
30         'field_id' => '11',
31         'field_name' => 'field_file',
32         'entity_type' => 'user',
33         'bundle' => 'user',
34         'data' => 'a:0:{}',
35         'deleted' => '0',
36       ],
37     ];
38     $tests[0]['source_data']['field_data_field_file'] = [
39       [
40         'entity_type' => 'user',
41         'bundle' => 'user',
42         'deleted' => 0,
43         'entity_id' => 2,
44         'revision_id' => NULL,
45         'language' => 'und',
46         'delta' => 0,
47         'field_file_fid' => 99,
48         'field_file_display' => 1,
49         'field_file_description' => 'None',
50       ],
51     ];
52     $tests[0]['source_data']['role'] = [
53       [
54         'rid' => 2,
55         'name' => 'authenticated user',
56         'weight' => 0,
57       ],
58     ];
59     $tests[0]['source_data']['users'] = [
60       [
61         'uid' => '2',
62         'name' => 'Odo',
63         'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8',
64         'mail' => 'odo@local.host',
65         'theme' => '',
66         'signature' => '',
67         'signature_format' => 'filtered_html',
68         'created' => '1432750741',
69         'access' => '0',
70         'login' => '0',
71         'status' => '1',
72         'timezone' => 'America/Chicago',
73         'language' => '',
74         'picture' => '0',
75         'init' => 'odo@local.host',
76         'data' => 'a:1:{s:7:"contact";i:1;}',
77       ],
78     ];
79     $tests[0]['source_data']['users_roles'] = [
80       [
81         'uid' => 2,
82         'rid' => 2,
83       ],
84     ];
85
86     // The expected results.
87     $tests[0]['expected_data'] = [
88       [
89         'uid' => '2',
90         'name' => 'Odo',
91         'pass' => '$S$DVpvPItXvnsmF3giVEe7Jy2lG.SCoEs8uKwpHsyPvdeNAaNZYxZ8',
92         'mail' => 'odo@local.host',
93         'signature' => '',
94         'signature_format' => 'filtered_html',
95         'created' => '1432750741',
96         'access' => '0',
97         'login' => '0',
98         'status' => '1',
99         'timezone' => 'America/Chicago',
100         'language' => '',
101         'picture' => '0',
102         'init' => 'odo@local.host',
103         'roles' => [2],
104         'data' => [
105           'contact' => 1,
106         ],
107         'field_file' => [
108           [
109             'fid' => 99,
110             'display' => 1,
111             'description' => 'None',
112           ],
113         ],
114       ],
115     ];
116
117     return $tests;
118   }
119
120 }