Problem/Motivation

Same problem as in #2313241: d6_taxonomy_term migrate fails when the parent term has not been already migrated.

The bug was reintroduced in #2348875: Improving our dump files.

git show ec9a3ec27da1c9f2cb6a4568e8fae5f4b1b54c32 -- core/modules/migrate_drupal/src/Tests/d6/MigrateTaxonomyTermTest.php shows the bad change.

Proposed resolution

Add explicit test coverage for stubbed taxonomy terms.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webflo created an issue. See original summary.

webflo’s picture

Status: Active » Needs review
FileSize
778 bytes
webflo’s picture

FileSize
1.04 KB
webflo’s picture

The test in #3 didn't fail because migrate catches all exceptions in destination and process plugins.

Status: Needs review » Needs work

The last submitted patch, 4: 2590215-4-test-only.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review
FileSize
2.86 KB
+++ b/core/modules/taxonomy/src/Plugin/migrate/destination/EntityTaxonomyTerm.php
@@ -20,11 +20,15 @@ class EntityTaxonomyTerm extends EntityContentBase {
+    $row->setDestinationProperty('default_langcode', TRUE);

The default_langcode is not required.

webflo’s picture

Title: Term migration is broken » d6_taxonomy_term migrate fails when the parent term has not been already migrated
Issue summary: View changes
webflo’s picture

Title: d6_taxonomy_term migrate fails when the parent term has not been already migrated » Regression: d6_taxonomy_term migrate fails when the parent term has not been already migrated
Issue summary: View changes
phenaproxima’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

This looks good to me but I'd like to see a dedicated test of the EntityTaxonomyTerm destination. It could be a kernel test that passes a stub row to import() and ensure that it's created as expected, without exceptions.

webflo’s picture

phenaproxima’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests
  1. +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/destination/EntityTaxonomyTermTest.php
    @@ -0,0 +1,63 @@
    +<?php
    +
    +namespace Drupal\Tests\taxonomy\Kernel\Plugin\migrate\destination;
    

    Missing @file comment.

  2. +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/destination/EntityTaxonomyTermTest.php
    @@ -0,0 +1,63 @@
    +    $migration = Migration::create($config);
    +    $destination = $migration->getDestinationPlugin();
    

    Nit: This can be a single line. Migration::create($config)->getDestinationPlugin()

  3. +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/destination/EntityTaxonomyTermTest.php
    @@ -0,0 +1,63 @@
    +    // Stub without name.
    

    Can this be a little more verbose?

  4. +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/destination/EntityTaxonomyTermTest.php
    @@ -0,0 +1,63 @@
    +    /**
    +     * @var TermInterface $term
    +     */
    

    Nit: Should be /** @var ... */, all on one line. And TermInterface should be the fully-qualified name of the interface.

  5. +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/destination/EntityTaxonomyTermTest.php
    @@ -0,0 +1,63 @@
    +    $this->assertEquals('Stub name for source tid:1', $term->getName());
    +    $this->assertEquals(0, $term->getWeight());
    

    assertSame() is preferred over assertEquals().

  6. +++ b/core/modules/taxonomy/tests/src/Kernel/Plugin/migrate/destination/EntityTaxonomyTermTest.php
    @@ -0,0 +1,63 @@
    +    // Stub with name.
    

    As with before, can this be better explained?

webflo’s picture

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Prime.

mikeryan’s picture

Status: Reviewed & tested by the community » Postponed
mikeryan’s picture

Status: Postponed » Closed (duplicate)