Version 1
[yaffs-website] / web / core / modules / taxonomy / tests / src / Kernel / Plugin / migrate / source / d6 / TermNodeTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
4
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
6
7 /**
8  * Tests d6_term_node source plugin.
9  *
10  * @covers \Drupal\taxonomy\Plugin\migrate\source\d6\TermNode
11  * @group taxonomy
12  */
13 class TermNodeTest extends MigrateSqlSourceTestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['taxonomy', 'migrate_drupal'];
19
20   /**
21    * {@inheritdoc}
22    */
23   public function providerSource() {
24     $tests = [];
25
26     // The source data.
27     $tests[0]['source_data']['term_node'] = [
28       [
29         'nid' => '1',
30         'vid' => '1',
31         'tid' => '1',
32       ],
33       [
34         'nid' => '1',
35         'vid' => '1',
36         'tid' => '4',
37       ],
38       [
39         'nid' => '1',
40         'vid' => '1',
41         'tid' => '5',
42       ],
43     ];
44     $tests[0]['source_data']['node'] = [
45       [
46         'nid' => '1',
47         'vid' => '1',
48         'type' => 'story',
49         'language' => '',
50         'title' => 'Test title',
51         'uid' => '1',
52         'status' => '1',
53         'created' => '1388271197',
54         'changed' => '1420861423',
55         'comment' => '0',
56         'promote' => '0',
57         'moderate' => '0',
58         'sticky' => '0',
59         'tnid' => '0',
60         'translate' => '0',
61       ],
62     ];
63     $tests[0]['source_data']['term_data'] = [
64       [
65         'tid' => '1',
66         'vid' => '3',
67         'name' => 'term 1 of vocabulary 3',
68         'description' => 'description of term 1 of vocabulary 3',
69         'weight' => '0',
70       ],
71       [
72         'tid' => '4',
73         'vid' => '3',
74         'name' => 'term 4 of vocabulary 3',
75         'description' => 'description of term 4 of vocabulary 3',
76         'weight' => '6',
77       ],
78       [
79         'tid' => '5',
80         'vid' => '3',
81         'name' => 'term 5 of vocabulary 3',
82         'description' => 'description of term 5 of vocabulary 3',
83         'weight' => '7',
84       ],
85     ];
86
87     // The expected results.
88     $tests[0]['expected_data'] = [
89       [
90         'nid' => 1,
91         'vid' => 1,
92         'type' => 'story',
93         'tid' => [1, 4, 5],
94       ],
95     ];
96
97     // Set default value for expected count.
98     $tests[0]['expected_count'] = NULL;
99
100     // Set plugin configuration.
101     $tests[0]['configuration'] = [
102       'vid' => 3,
103     ];
104
105     return $tests;
106   }
107
108 }