class MigrateDrupal7AuditIdsTest
Same name in this branch
- 9 core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest
Same name and namespace in other branches
- 11.x core/modules/migrate_drupal/tests/src/Kernel/d7/MigrateDrupal7AuditIdsTest.php \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7AuditIdsTest
Tests the migration auditor for ID conflicts.
@group aggregator @group legacy
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\migrate\MigrateMessageInterface implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase implements \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\aggregator\Kernel\Migrate\d7\MigrateDrupal7TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\aggregator\Kernel\Migrate\d7\MigrateDrupal7AuditIdsTest implements \Drupal\Tests\aggregator\Kernel\Migrate\d7\MigrateDrupal7TestBase
- class \Drupal\Tests\aggregator\Kernel\Migrate\d7\MigrateDrupal7TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase implements \Drupal\Tests\migrate\Kernel\MigrateTestBase
- class \Drupal\Tests\migrate\Kernel\MigrateTestBase extends \Drupal\migrate\MigrateMessageInterface implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of MigrateDrupal7AuditIdsTest
File
-
core/
modules/ aggregator/ tests/ src/ Kernel/ Migrate/ d7/ MigrateDrupal7AuditIdsTest.php, line 14
Namespace
Drupal\Tests\aggregator\Kernel\Migrate\d7View source
class MigrateDrupal7AuditIdsTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'file',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Install required schemas.
$this->installEntitySchema('aggregator_feed');
$this->installEntitySchema('aggregator_item');
$this->installEntitySchema('file');
}
/**
* Tests all migrations with ID conflicts.
*/
public function testAllMigrationsWithIdConflicts() {
$migrations = $this->container
->get('plugin.manager.migration')
->createInstancesByTag('Drupal 7');
// Create content.
$entity_type_manager = \Drupal::entityTypeManager();
// Create an aggregator feed.
if ($entity_type_manager->hasDefinition('aggregator_feed')) {
$feed = $entity_type_manager->getStorage('aggregator_feed')
->create([
'title' => 'feed',
'url' => 'http://www.example.com',
]);
$feed->save();
// Create an aggregator feed item.
$item = $entity_type_manager->getStorage('aggregator_item')
->create([
'title' => 'feed item',
'fid' => $feed->id(),
'link' => 'http://www.example.com',
]);
$item->save();
}
// Audit the IDs of all Drupal 7 migrations. There should be conflicts since
// content has been created.
$conflicts = array_map(function (AuditResult $result) {
return $result->passed() ? NULL : $result->getMigration()
->getBaseId();
}, (new IdAuditor())->auditMultiple($migrations));
$expected = [
'd7_aggregator_feed',
'd7_aggregator_item',
];
$this->assertEmpty(array_diff(array_filter($conflicts), $expected));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.