145863790e0c08a0d01a76a40a7acda9f011d447
[yaffs-website] / web / core / modules / menu_link_content / tests / src / Functional / Update / MenuLinkContentUpdateTest.php
1 <?php
2
3 namespace Drupal\Tests\menu_link_content\Functional\Update;
4
5 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
6 use Drupal\user\Entity\User;
7
8 /**
9  * Tests the upgrade path for custom menu links.
10  *
11  * @group menu_link_content
12  * @group Update
13  * @group legacy
14  */
15 class MenuLinkContentUpdateTest extends UpdatePathTestBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   protected function setDatabaseDumpFiles() {
21     $this->databaseDumpFiles = [
22       __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
23     ];
24   }
25
26   /**
27    * Tests the addition of the publishing status entity key.
28    *
29    * @see menu_link_content_update_8601()
30    */
31   public function testPublishedEntityKeyAddition() {
32     $this->runUpdates();
33
34     // Log in as user 1.
35     $account = User::load(1);
36     $account->passRaw = 'drupal';
37     $this->drupalLogin($account);
38
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');
43
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',
51     ]);
52     $menu_link->save();
53
54     $menu_link = $storage->loadUnchanged($menu_link->id());
55
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());
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   protected function replaceUser1() {
66     // Do not replace the user from our dump.
67   }
68
69 }