You are here

public function MenuBlockTest::testMenuBlockParent in Menu Block 8

Tests the menu_block parent option.

File

tests/src/Functional/MenuBlockTest.php, line 338

Class

MenuBlockTest
Tests for the menu_block module.

Namespace

Drupal\Tests\menu_block\Functional

Code

public function testMenuBlockParent() {
  $block_id = 'main';
  $this
    ->drupalGet('admin/structure/block/add/menu_block:main');
  $this
    ->submitForm([
    'id' => $block_id,
    'settings[label]' => 'Main navigation',
    'settings[label_display]' => FALSE,
    'settings[parent]' => 'main:' . $this->links['parent'],
    'region' => 'primary_menu',
  ], 'Save block');
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->pageTextNotContains('parent menu item');
  $this
    ->assertSession()
    ->pageTextContains('child-1 menu item');
  $this
    ->assertSession()
    ->pageTextNotContains('child-1-1 menu item');
  $this
    ->drupalGet('admin/structure/block/manage/' . $block_id);
  $this
    ->submitForm([
    'settings[parent]' => 'main:' . $this->links['child-1'],
  ], 'Save block');
  $this
    ->assertSession()
    ->pageTextNotContains('parent menu item');
  $this
    ->assertSession()
    ->pageTextNotContains('child-1 menu item');
  $this
    ->assertSession()
    ->pageTextContains('child-1-1 menu item');
  $this
    ->assertSession()
    ->pageTextContains('child-1-2 menu item');
}