flag-8.x-4.x-dev/tests/src/Kernel/MigrateDrupal6FlagTest.php
tests/src/Kernel/MigrateDrupal6FlagTest.php
<?php
namespace Drupal\Tests\flag\Kernel;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Tests migration of flags.
*
* @group flag
*/
class MigrateDrupal6FlagTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
'node',
'comment',
'taxonomy',
'text',
'menu_ui',
'flag',
];
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$fixture = __DIR__ . '/../../fixtures/drupal6.php';
$this->assertNotFalse(realpath($fixture));
$this->loadFixture($fixture);
$this->installEntitySchema('flag');
$this->installEntitySchema('node_type');
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installEntitySchema('comment_type');
$this->installEntitySchema('comment');
$this->installEntitySchema('taxonomy_term');
$this->installEntitySchema('taxonomy_vocabulary');
$this->installConfig(static::$modules);
$this->executeMigration('d6_comment_type');
$this->executeMigration('d6_node_type');
$this->executeMigration('d6_taxonomy_vocabulary');
$this->executeMigration('d6_flag');
}
/**
* Asserts that flags have been migrated.
*/
public function testMigrationResults() {
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */
$entityTypeManager = $this->container->get('entity_type.manager');
/** @var \Drupal\flag\Entity\Flag[] $flags */
$flags = $entityTypeManager
->getStorage('flag')
->loadMultiple();
$this->assertCount(4, $flags);
// Comments.
$this->assertEquals([
'article',
'comment_test_content_type',
], $flags['comment_flag']->getBundles());
// Nodes.
$this->assertEquals(['article', 'blog'], $flags['node_flag']->getBundles());
// User.
$this->assertEquals(['user'], $flags['user_flag']->getBundles());
// Node global.
$this->assertEquals(['article'], $flags['node_global_flag']->getBundles());
}
}
