class MigrateShortcutTest
Same name and namespace in other branches
- 11.x core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php \Drupal\Tests\shortcut\Kernel\Migrate\d7\MigrateShortcutTest
- 10 core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php \Drupal\Tests\shortcut\Kernel\Migrate\d7\MigrateShortcutTest
- 8.9.x core/modules/shortcut/tests/src/Kernel/Migrate/d7/MigrateShortcutTest.php \Drupal\Tests\shortcut\Kernel\Migrate\d7\MigrateShortcutTest
Test shortcut menu links migration to Shortcut entities.
@group shortcut
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\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase uses \Drupal\Tests\migrate_drupal\Traits\NodeMigrateTypeTestTrait implements \Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase
- class \Drupal\Tests\shortcut\Kernel\Migrate\d7\MigrateShortcutTest implements \Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase
- class \Drupal\Tests\migrate_drupal\Kernel\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 MigrateShortcutTest
File
-
core/
modules/ shortcut/ tests/ src/ Kernel/ Migrate/ d7/ MigrateShortcutTest.php, line 14
Namespace
Drupal\Tests\shortcut\Kernel\Migrate\d7View source
class MigrateShortcutTest extends MigrateDrupal7TestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'link',
'field',
'shortcut',
'menu_link_content',
];
/**
* {@inheritdoc}
*/
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');
}
/**
* Asserts various aspects of a shortcut entity.
*
* @param int $id
* The shortcut ID.
* @param string $title
* The expected title of the shortcut.
* @param int $weight
* The expected weight of the shortcut.
* @param string $url
* The expected URL of the shortcut.
*
* @internal
*/
protected function assertEntity(int $id, string $title, int $weight, string $url) : void {
$shortcut = Shortcut::load($id);
$this->assertInstanceOf(ShortcutInterface::class, $shortcut);
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
$this->assertSame($title, $shortcut->getTitle());
$this->assertSame($weight, (int) $shortcut->getWeight());
$this->assertSame($url, $shortcut->getUrl()
->toString());
}
/**
* Tests the shortcut migration.
*/
public function testShortcutMigration() {
// Check if the 4 shortcuts were migrated correctly.
$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');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.