Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2
This commit is contained in:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\vocabulary_serialization_test;
|
||||
|
||||
use Drupal\Core\Cache\CacheableResponse;
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
|
||||
class VocabularyResponse extends CacheableResponse {
|
||||
|
||||
/**
|
||||
* @var \Drupal\taxonomy\VocabularyInterface
|
||||
*/
|
||||
protected $vocabulary;
|
||||
|
||||
public function setVocabulary(VocabularyInterface $vocabulary) {
|
||||
$this->vocabulary = $vocabulary;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\vocabulary_serialization_test;
|
||||
|
||||
use Drupal\taxonomy\VocabularyInterface;
|
||||
|
||||
class VocabularySerializationTestController {
|
||||
|
||||
public function vocabularyResponse(VocabularyInterface $taxonomy_vocabulary) {
|
||||
$response = new VocabularyResponse('this is the output');
|
||||
$response->setVocabulary($taxonomy_vocabulary);
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
name: 'Vocabulary serialization test'
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- taxonomy
|
|
@ -0,0 +1,6 @@
|
|||
vocabulary_serialization_test:
|
||||
path: '/vocabulary_serialization_test/{taxonomy_vocabulary}'
|
||||
defaults:
|
||||
_controller: 'Drupal\vocabulary_serialization_test\VocabularySerializationTestController::vocabularyResponse'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Functional;
|
||||
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Regression test for https://www.drupal.org/node/2807263.
|
||||
*
|
||||
* When a Vocabulary entity is unserialized before the modules have been loaded
|
||||
* (which happens in the KernelPreHandle Stack middleware), then the constants
|
||||
* that the Vocabulary entity uses are not yet available because they are set in
|
||||
* taxonomy.module. This means that for example the PageCache middleware cannot
|
||||
* load any cached Vocabulary entity, because unserialization will fail.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularySerializationTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'vocabulary_serialization_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
Vocabulary::create(['vid' => 'test'])->save();
|
||||
}
|
||||
|
||||
public function testSerialization() {
|
||||
$this->drupalGet('/vocabulary_serialization_test/test');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
|
||||
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'MISS');
|
||||
|
||||
$this->drupalGet('/vocabulary_serialization_test/test');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$this->assertSame('this is the output', $this->getSession()->getPage()->getContent());
|
||||
$this->assertSession()->responseHeaderEquals('X-Drupal-Cache', 'HIT');
|
||||
}
|
||||
|
||||
}
|
|
@ -54,9 +54,9 @@ class MigrateTaxonomyVocabularyTest extends MigrateDrupal7TestBase {
|
|||
* Tests the Drupal 7 taxonomy vocabularies to Drupal 8 migration.
|
||||
*/
|
||||
public function testTaxonomyVocabulary() {
|
||||
$this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', TAXONOMY_HIERARCHY_DISABLED, 0);
|
||||
$this->assertEntity('forums', 'Forums', 'Forum navigation vocabulary', TAXONOMY_HIERARCHY_SINGLE, -10);
|
||||
$this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', TAXONOMY_HIERARCHY_SINGLE, 0);
|
||||
$this->assertEntity('tags', 'Tags', 'Use tags to group articles on similar topics into categories.', VocabularyInterface::HIERARCHY_DISABLED, 0);
|
||||
$this->assertEntity('forums', 'Forums', 'Forum navigation vocabulary', VocabularyInterface::HIERARCHY_SINGLE, -10);
|
||||
$this->assertEntity('test_vocabulary', 'Test Vocabulary', 'This is the vocabulary description', VocabularyInterface::HIERARCHY_SINGLE, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source;
|
||||
|
||||
/**
|
||||
* Tests the taxonomy term source with vocabulary filter.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\Term
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermSourceWithVocabularyFilterTest extends TermTest {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
// Get the source data from parent.
|
||||
$tests = parent::providerSource();
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => [1],
|
||||
],
|
||||
];
|
||||
|
||||
// We know there are two rows with vid == 5.
|
||||
$tests[0]['expected_count'] = 2;
|
||||
|
||||
// Set up source plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'vocabulary' => [5],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests taxonomy term source plugin.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\Term
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['term_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['term_hierarchy'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'parent' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
'parent' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
'parent' => 0,
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'parent' => 1,
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
'parent' => 2,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'parent' => 3,
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'parent' => 2,
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
'parent' => [0],
|
||||
],
|
||||
[
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => [1],
|
||||
],
|
||||
[
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
'parent' => [2],
|
||||
],
|
||||
[
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
'parent' => [3, 2],
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\taxonomy\Plugin\migrate\source\d6\TermNode;
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests d6_term_node source plugin.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\TermNode
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermNodeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = TermNode::class;
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_term_node',
|
||||
'vid' => 3,
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'story',
|
||||
'tid' => array(1, 4, 5),
|
||||
),
|
||||
);
|
||||
class TermNodeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['term_node'] = array(
|
||||
array(
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['term_node'] = [
|
||||
[
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'tid' => '1',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'tid' => '4',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'tid' => '5',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['node'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['node'] = [
|
||||
[
|
||||
'nid' => '1',
|
||||
'vid' => '1',
|
||||
'type' => 'story',
|
||||
|
@ -69,32 +58,51 @@ class TermNodeTest extends MigrateSqlSourceTestCase {
|
|||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['term_data'] = array(
|
||||
array(
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['term_data'] = [
|
||||
[
|
||||
'tid' => '1',
|
||||
'vid' => '3',
|
||||
'name' => 'term 1 of vocabulary 3',
|
||||
'description' => 'description of term 1 of vocabulary 3',
|
||||
'weight' => '0',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'tid' => '4',
|
||||
'vid' => '3',
|
||||
'name' => 'term 4 of vocabulary 3',
|
||||
'description' => 'description of term 4 of vocabulary 3',
|
||||
'weight' => '6',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'tid' => '5',
|
||||
'vid' => '3',
|
||||
'name' => 'term 5 of vocabulary 3',
|
||||
'description' => 'description of term 5 of vocabulary 3',
|
||||
'weight' => '7',
|
||||
),
|
||||
);
|
||||
parent::setUp();
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'story',
|
||||
'tid' => [1, 4, 5],
|
||||
],
|
||||
];
|
||||
|
||||
// Set default value for expected count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// Set plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'vid' => 3,
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 vocabulary source plugin.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['vocabulary'] = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'help' => 1,
|
||||
'relations' => 0,
|
||||
'hierarchy' => 0,
|
||||
'multiple' => 0,
|
||||
'required' => 0,
|
||||
'tags' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'help' => 1,
|
||||
'relations' => 1,
|
||||
'hierarchy' => 1,
|
||||
'multiple' => 0,
|
||||
'required' => 1,
|
||||
'tags' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['vocabulary_node_types'] = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
],
|
||||
[
|
||||
'vid' => 1,
|
||||
'type' => 'article',
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'type' => 'article',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'help' => 1,
|
||||
'relations' => 0,
|
||||
'hierarchy' => 0,
|
||||
'multiple' => 0,
|
||||
'required' => 0,
|
||||
'tags' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['page', 'article'],
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'help' => 1,
|
||||
'relations' => 1,
|
||||
'hierarchy' => 1,
|
||||
'multiple' => 0,
|
||||
'required' => 1,
|
||||
'tags' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['article'],
|
||||
'cardinality' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 vocabulary source plugin.
|
||||
*
|
||||
* @covers \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['taxonomy', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['taxonomy_vocabulary'] = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'hierarchy' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'machine_name' => 'tags',
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'hierarchy' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'machine_name' => 'categories',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = $tests[0]['source_data']['taxonomy_vocabulary'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate;
|
||||
|
||||
/**
|
||||
* Tests the taxonomy term source with vocabulary filter.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermSourceWithVocabularyFilterTest extends TermTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['source']['vocabulary'] = array(5);
|
||||
parent::setUp();
|
||||
$this->expectedResults = array_values(array_filter($this->expectedResults, function($result) {
|
||||
return $result['vid'] == 5;
|
||||
}));
|
||||
// We know there are two rows with vid == 5.
|
||||
$this->expectedCount = 2;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate;
|
||||
|
||||
/**
|
||||
* Tests taxonomy term source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class TermTest extends TermTestBase {
|
||||
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for taxonomy term source unit tests.
|
||||
*/
|
||||
abstract class TermTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\Term';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_taxonomy_term',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'tid' => 1,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 1',
|
||||
'description' => 'description value 1',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 2,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 2',
|
||||
'description' => 'description value 2',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 3,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 3',
|
||||
'description' => 'description value 3',
|
||||
'weight' => 0,
|
||||
'parent' => array(0),
|
||||
),
|
||||
array(
|
||||
'tid' => 4,
|
||||
'vid' => 5,
|
||||
'name' => 'name value 4',
|
||||
'description' => 'description value 4',
|
||||
'weight' => 1,
|
||||
'parent' => array(1),
|
||||
),
|
||||
array(
|
||||
'tid' => 5,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 5',
|
||||
'description' => 'description value 5',
|
||||
'weight' => 1,
|
||||
'parent' => array(2),
|
||||
),
|
||||
array(
|
||||
'tid' => 6,
|
||||
'vid' => 6,
|
||||
'name' => 'name value 6',
|
||||
'description' => 'description value 6',
|
||||
'weight' => 0,
|
||||
'parent' => array(3, 2),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
foreach ($row['parent'] as $parent) {
|
||||
$this->databaseContents['term_hierarchy'][] = array(
|
||||
'tid' => $row['tid'],
|
||||
'parent' => $parent,
|
||||
);
|
||||
}
|
||||
unset($row['parent']);
|
||||
$this->databaseContents['term_data'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
||||
/**
|
||||
* Tests D6 vocabulary source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd6_vocabulary',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'help' => 1,
|
||||
'relations' => 0,
|
||||
'hierarchy' => 0,
|
||||
'multiple' => 0,
|
||||
'required' => 0,
|
||||
'tags' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['page', 'article'],
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'help' => 1,
|
||||
'relations' => 1,
|
||||
'hierarchy' => 1,
|
||||
'multiple' => 0,
|
||||
'required' => 1,
|
||||
'tags' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'node_types' => ['article'],
|
||||
'cardinality' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as &$row) {
|
||||
foreach ($row['node_types'] as $type) {
|
||||
$this->databaseContents['vocabulary_node_types'][] = [
|
||||
'type' => $type,
|
||||
'vid' => $row['vid'],
|
||||
];
|
||||
}
|
||||
unset($row['node_types']);
|
||||
}
|
||||
$this->databaseContents['vocabulary'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\taxonomy\Unit\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 vocabulary source plugin.
|
||||
*
|
||||
* @group taxonomy
|
||||
*/
|
||||
class VocabularyTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_vocabulary',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'vid' => 1,
|
||||
'name' => 'Tags',
|
||||
'description' => 'Tags description.',
|
||||
'hierarchy' => 0,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'machine_name' => 'tags',
|
||||
],
|
||||
[
|
||||
'vid' => 2,
|
||||
'name' => 'Categories',
|
||||
'description' => 'Categories description.',
|
||||
'hierarchy' => 1,
|
||||
'module' => 'taxonomy',
|
||||
'weight' => 0,
|
||||
'machine_name' => 'categories',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['taxonomy_vocabulary'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue