MigrateShortcutSetTest.php in Drupal 10
File
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutSetTest.php
View source
<?php
namespace Drupal\Tests\shortcut\Kernel\Migrate\d7;
use Drupal\shortcut\Entity\ShortcutSet;
use Drupal\shortcut\ShortcutSetInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
class MigrateShortcutSetTest extends MigrateDrupal7TestBase {
protected static $modules = [
'link',
'field',
'shortcut',
'menu_link_content',
];
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('shortcut');
$this
->installEntitySchema('menu_link_content');
$this
->executeMigration('d7_shortcut_set');
$this
->executeMigration('d7_menu');
$this
->executeMigration('d7_shortcut');
}
public function testShortcutSetMigration() {
$this
->assertEntity('default', 'Default', 2);
$this
->assertEntity('shortcut_set_2', 'Alternative shortcut set', 2);
}
protected function assertEntity(string $id, string $label, int $expected_size) : void {
$shortcut_set = ShortcutSet::load($id);
$this
->assertInstanceOf(ShortcutSetInterface::class, $shortcut_set);
$this
->assertSame($id, $shortcut_set
->id());
$this
->assertSame($label, $shortcut_set
->label());
$shortcuts = $shortcut_set
->getShortcuts();
$this
->assertCount($expected_size, $shortcuts);
}
}