3 namespace Drupal\Tests\menu_link_content\Functional\Update;
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\user\Entity\User;
9 * Tests the upgrade path for custom menu links.
11 * @group menu_link_content
15 class MenuLinkContentUpdateTest extends UpdatePathTestBase {
20 protected function setDatabaseDumpFiles() {
21 $this->databaseDumpFiles = [
22 __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
27 * Tests the addition of the publishing status entity key.
29 * @see menu_link_content_update_8601()
31 public function testPublishedEntityKeyAddition() {
35 $account = User::load(1);
36 $account->passRaw = 'drupal';
37 $this->drupalLogin($account);
39 // Make sure our custom menu link exists.
40 $assert_session = $this->assertSession();
41 $this->drupalGet('admin/structure/menu/item/1/edit');
42 $assert_session->checkboxChecked('edit-enabled-value');
44 // Check that custom menu links can be created, saved and then loaded.
45 $storage = \Drupal::entityTypeManager()->getStorage('menu_link_content');
46 /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
47 $menu_link = $storage->create([
48 'menu_name' => 'main',
49 'link' => 'route:user.page',
50 'title' => 'Pineapple',
54 $menu_link = $storage->loadUnchanged($menu_link->id());
56 $this->assertEquals('main', $menu_link->getMenuName());
57 $this->assertEquals('Pineapple', $menu_link->label());
58 $this->assertEquals('route:user.page', $menu_link->link->uri);
59 $this->assertTrue($menu_link->isPublished());
65 protected function replaceUser1() {
66 // Do not replace the user from our dump.