MigrateShortcutTest.php in Drupal 9
File
core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php
View source
<?php
namespace Drupal\Tests\shortcut\Kernel\Migrate\d7;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\shortcut\ShortcutInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
class MigrateShortcutTest 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');
}
protected function assertEntity($id, $title, $weight, $url) {
$shortcut = Shortcut::load($id);
$this
->assertInstanceOf(ShortcutInterface::class, $shortcut);
$this
->assertSame($title, $shortcut
->getTitle());
$this
->assertSame($weight, $shortcut
->getWeight());
$this
->assertSame($url, $shortcut
->getUrl()
->toString());
}
public function testShortcutMigration() {
$this
->assertEntity(1, 'Add content', '-20', '/node/add');
$this
->assertEntity(2, 'Find content', '-19', '/admin/content');
$this
->assertEntity(3, 'Help', '-49', '/admin/help');
$this
->assertEntity(4, 'People', '-50', '/admin/people');
}
}