diff -u b/core/modules/migrate/src/Audit/IdAuditor.php b/core/modules/migrate/src/Audit/IdAuditor.php --- b/core/modules/migrate/src/Audit/IdAuditor.php +++ b/core/modules/migrate/src/Audit/IdAuditor.php @@ -18,8 +18,9 @@ public function audit(MigrationInterface $migration) { $plugin_definition = $migration->getPluginDefinition(); + // If the migration does not opt into auditing, it passes. if (empty($plugin_definition['audit'])) { - return []; + return AuditResult::pass($migration); } $interface = MaximumValueInterface::class; diff -u b/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php --- b/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/d6/MigrateDrupal6AuditIdsTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\migrate_drupal\Kernel\d6; use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait; +use Drupal\migrate\Audit\AuditResult; use Drupal\migrate\Audit\IdAuditor; use Drupal\node\Entity\Node; use Drupal\Tests\migrate_drupal\Kernel\CreateContentTrait; @@ -68,7 +69,13 @@ $this->getMigration('d6_node:page'), $this->getMigration('d6_node:article'), ]; - $this->assertEmpty((new IdAuditor())->auditMultiple($migrations)); + + $results = (new IdAuditor())->auditMultiple($migrations); + /** @var \Drupal\migrate\Audit\AuditResult $result */ + foreach ($results as $result) { + $this->assertInstanceOf(AuditResult::class, $result); + $this->assertTrue($result->passed()); + } } /** @@ -81,7 +88,12 @@ // Audit all Drupal 6 migrations that support it. There should be no // conflicts since no content has been created. - $this->assertEmpty((new IdAuditor())->auditMultiple($migrations)); + $results = (new IdAuditor())->auditMultiple($migrations); + /** @var \Drupal\migrate\Audit\AuditResult $result */ + foreach ($results as $result) { + $this->assertInstanceOf(AuditResult::class, $result); + $this->assertTrue($result->passed()); + } } /** @@ -98,7 +110,12 @@ // Audit the IDs of all migrations. There should be conflicts since content // has been created. - $conflicts = (new IdAuditor())->auditMultiple($migrations); + $conflicts = array_map( + function (AuditResult $result) { + return $result->passed() ? NULL : $result->getMigration()->getBaseId(); + }, + (new IdAuditor())->auditMultiple($migrations) + ); $expected = [ 'd6_aggregator_feed', @@ -113,8 +130,7 @@ 'd6_term_node_revision', 'd6_user', ]; - - $this->assertSame($expected, array_keys($conflicts)); + $this->assertEmpty(array_diff(array_filter($conflicts), $expected)); } } diff -u b/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php --- b/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\migrate_drupal\Kernel\d7; use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait; +use Drupal\migrate\Audit\AuditResult; use Drupal\migrate\Audit\IdAuditor; use Drupal\node\Entity\Node; use Drupal\Tests\migrate_drupal\Kernel\CreateContentTrait; @@ -68,7 +69,13 @@ $this->getMigration('d7_node:page'), $this->getMigration('d7_node:article'), ]; - $this->assertEmpty((new IdAuditor())->auditMultiple($migrations)); + + $results = (new IdAuditor())->auditMultiple($migrations); + /** @var \Drupal\migrate\Audit\AuditResult $result */ + foreach ($results as $result) { + $this->assertInstanceOf(AuditResult::class, $result); + $this->assertTrue($result->passed()); + } } /** @@ -81,7 +88,12 @@ // Audit the IDs of all Drupal 7 migrations. There should be no conflicts // since no content has been created. - $this->assertEmpty((new IdAuditor())->auditMultiple($migrations)); + $results = (new IdAuditor())->auditMultiple($migrations); + /** @var \Drupal\migrate\Audit\AuditResult $result */ + foreach ($results as $result) { + $this->assertInstanceOf(AuditResult::class, $result); + $this->assertTrue($result->passed()); + } } /** @@ -97,7 +109,12 @@ // Audit the IDs of all Drupal 7 migrations. There should be conflicts since // content has been created. - $conflicts = (new IdAuditor())->auditMultiple($migrations); + $conflicts = array_map( + function (AuditResult $result) { + return $result->passed() ? NULL : $result->getMigration()->getBaseId(); + }, + (new IdAuditor())->auditMultiple($migrations) + ); $expected = [ 'd7_aggregator_feed', @@ -112,8 +129,7 @@ 'd7_taxonomy_term', 'd7_user', ]; - - $this->assertSame($expected, array_keys($conflicts)); + $this->assertEmpty(array_diff(array_filter($conflicts), $expected)); } } only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\ContentEntityType; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\migrate\MigrateException; @@ -39,6 +40,11 @@ class EntityContentBaseTest extends UnitTestCase { protected $storage; /** + * @var \Drupal\Core\Entity\EntityTypeInterface + */ + protected $entityType; + + /** * @var \Drupal\Core\Entity\EntityManagerInterface */ protected $entityManager; @@ -51,6 +57,11 @@ protected function setUp() { $this->migration = $this->prophesize(MigrationInterface::class); $this->storage = $this->prophesize(EntityStorageInterface::class); + + $this->entityType = $this->prophesize(EntityTypeInterface::class); + $this->entityType->getPluralLabel()->willReturn('wonkiness'); + $this->storage->getEntityType()->willReturn($this->entityType->reveal()); + $this->entityManager = $this->prophesize(EntityManagerInterface::class); } @@ -104,14 +115,11 @@ public function testImportEntityLoadFailure() { */ public function testUntranslatable() { // An entity type without a language. - $entity_type = $this->prophesize(ContentEntityType::class); - $entity_type->getKey('langcode')->willReturn(''); - $entity_type->getKey('id')->willReturn('id'); + $this->entityType->getKey('langcode')->willReturn(''); + $this->entityType->getKey('id')->willReturn('id'); $this->entityManager->getBaseFieldDefinitions('foo') ->willReturn(['id' => BaseFieldDefinitionTest::create('integer')]); - $this->storage->getEntityType()->willReturn($entity_type->reveal()); - $destination = new EntityTestDestination( ['translations' => TRUE], '', only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityTypeInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\destination\EntityRevision as RealEntityRevision; use Drupal\migrate\Row; @@ -48,6 +49,11 @@ protected function setUp() { // Setup mocks to be used when creating a revision destination. $this->migration = $this->prophesize(MigrationInterface::class); $this->storage = $this->prophesize('\Drupal\Core\Entity\EntityStorageInterface'); + + $entity_type = $this->prophesize(EntityTypeInterface::class); + $entity_type->getPluralLabel()->willReturn('craziness'); + $this->storage->getEntityType()->willReturn($entity_type->reveal()); + $this->entityManager = $this->prophesize('\Drupal\Core\Entity\EntityManagerInterface'); $this->fieldTypeManager = $this->prophesize('\Drupal\Core\Field\FieldTypePluginManagerInterface'); } only in patch2: unchanged: --- a/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/MigrateDrupalTestBase.php @@ -3,6 +3,8 @@ namespace Drupal\Tests\migrate_drupal\Kernel; use Drupal\Core\Database\Database; +use Drupal\migrate\Audit\AuditResult; +use Drupal\migrate\Audit\IdAuditor; use Drupal\Tests\migrate\Kernel\MigrateTestBase; /**