3 namespace Drupal\Tests\shortcut\Kernel\Migrate\d7;
5 use Drupal\shortcut\Entity\ShortcutSet;
6 use Drupal\shortcut\ShortcutSetInterface;
7 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
10 * Test shortcut_set migration to ShortcutSet entities.
14 class MigrateShortcutSetTest extends MigrateDrupal7TestBase {
21 public static $modules = [
31 protected function setUp() {
33 $this->installEntitySchema('shortcut');
34 $this->installEntitySchema('menu_link_content');
35 \Drupal::service('router.builder')->rebuild();
36 $this->executeMigration('d7_shortcut_set');
37 $this->executeMigration('d7_menu');
38 $this->executeMigration('d7_menu_links');
39 $this->executeMigration('d7_shortcut');
43 * Test the shortcut set migration.
45 public function testShortcutSetMigration() {
46 $this->assertEntity('default', 'Default', 2);
47 $this->assertEntity('shortcut_set_2', 'Alternative shortcut set', 2);
51 * Asserts various aspects of a shortcut set entity.
54 * The expected shortcut set ID.
55 * @param string $label
56 * The expected shortcut set label.
57 * @param int $expected_size
58 * The number of shortcuts expected to be in the set.
60 protected function assertEntity($id, $label, $expected_size) {
61 $shortcut_set = ShortcutSet::load($id);
62 $this->assertTrue($shortcut_set instanceof ShortcutSetInterface);
63 /** @var \Drupal\shortcut\ShortcutSetInterface $shortcut_set */
64 $this->assertIdentical($id, $shortcut_set->id());
65 $this->assertIdentical($label, $shortcut_set->label());
67 // Check the number of shortcuts in the set.
68 $shortcuts = $shortcut_set->getShortcuts();
69 $this->assertIdentical(count($shortcuts), $expected_size);