diff --git a/core/modules/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php b/core/modules/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php index f8a362eef2..25d0906a36 100644 --- a/core/modules/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php +++ b/core/modules/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php @@ -13,7 +13,7 @@ class BookTest extends MigrateSqlSourceTestBase { /** * {@inheritdoc} */ - public static $modules = ['user', 'node', 'book', 'migrate_drupal']; + public static $modules = ['book', 'migrate_drupal', 'node']; /** * {@inheritdoc} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php index e087d369d0..f9a0420a69 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php @@ -13,7 +13,31 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Content entity source from the current version of Drupal. + * Source plugin to get content entities from the current version of Drupal. + * + * Available configuration keys: + * - bundle: (optional) String, if the entity type is bundleable, only return + * entities of this bundle. + * - exclude_translations: (optional) Boolean, indicates if the entity + * translations should be excluded, default to FALSE. + * + * Examples: + * + * This will return all nodes, from every bundles (if this entity type is + * bundleable) and every translations (if this entity type is translatable). + * @code + * source: + * plugin: content_entity:node + * @endcode + * + * This will only return nodes of type 'article' bundle in their default + * language. + * @code + * source: + * plugin: content_entity:node + * bundle: article + * exclude_translations: true + * @endcode * * @MigrateSource( * id = "content_entity", diff --git a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php index 0607b7535a..2fa1d321fb 100755 --- a/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/Plugin/migrate/source/ContentEntityTest.php @@ -109,8 +109,8 @@ protected function setUp() { ConfigurableLanguage::createFromLangcode('fr')->save(); // Create article content type. - $nodeType = NodeType::create(['type' => $this->bundle, 'name' => 'Article']); - $nodeType->save(); + $node_type = NodeType::create(['type' => $this->bundle, 'name' => 'Article']); + $node_type->save(); // Create a vocabulary. $vocabulary = Vocabulary::create([ @@ -334,7 +334,6 @@ public function testTermSource() { 'exclude_translations' => TRUE, 'bundle' => $this->vocabulary, ]; - $taxonomy_term_storage = $this->container->get('entity_type.manager')->getStorage('taxonomy_term'); $migration = $this->migrationPluginManager->createStubMigration($this->migrationDefinition('content_entity:taxonomy_term')); $term_source = $this->sourcePluginManager->createInstance('content_entity:taxonomy_term', $configuration, $migration); $this->assertSame('taxonomy term entities', $term_source->__toString()); @@ -350,16 +349,15 @@ public function testTermSource() { $values = $term_source->current()->getSource(); $this->assertEquals($this->vocabulary, $values['vid'][0]['target_id']); $this->assertEquals(1, $values['tid']); - $parents = $taxonomy_term_storage->loadParents($values['tid']); - $this->assertEmpty($parents); + // @TODO: Add test coverage for parent in + // https://www.drupal.org/project/drupal/issues/2940198 $this->assertEquals('Apples', $values['name'][0]['value']); $term_source->next(); $values = $term_source->current()->getSource(); $this->assertEquals($this->vocabulary, $values['vid'][0]['target_id']); $this->assertEquals(2, $values['tid']); - $parents = $taxonomy_term_storage->loadParents($values['tid']); - $parent = reset($parents); - $this->assertEquals(1, $parent->id()); + // @TODO: Add test coverage for parent in + // https://www.drupal.org/project/drupal/issues/2940198 $this->assertEquals('Granny Smith', $values['name'][0]['value']); }