You are here

public function TokenMenuTest::testPreviewMenuLink in Token 8

Tests that no menu link is generated when the node gets previewed.

File

tests/src/Functional/TokenMenuTest.php, line 462

Class

TokenMenuTest
Tests menu tokens.

Namespace

Drupal\Tests\token\Functional

Code

public function testPreviewMenuLink() {
  $this
    ->drupalCreateContentType([
    'type' => 'article',
  ]);
  $permissions = [
    'access administration pages',
    'administer content types',
    'create article content',
    'edit any article content',
    'administer menu',
  ];
  $this
    ->drupalLogin($this
    ->drupalCreateUser($permissions));

  // Create an english node with an english menu.
  $this
    ->drupalGet('/node/add/article');
  $edit = [
    'title[0][value]' => 'English test node with menu',
    'menu[enabled]' => TRUE,
    'menu[title]' => 'English menu title',
  ];
  $this
    ->drupalGet('node/add/article');
  $this
    ->submitForm($edit, 'Preview');
  $menu_links = \Drupal::entityTypeManager()
    ->getStorage('menu_link_content')
    ->loadByProperties([
    'menu_name' => 'main',
  ]);
  $this
    ->assertEmpty($menu_links);
}