You are here

public function MenuBlockTest::testMenuBlockUi in Menu Block 8

Checks if all menu block settings are saved correctly.

File

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

Class

MenuBlockTest
Tests for the menu_block module.

Namespace

Drupal\Tests\menu_block\Functional

Code

public function testMenuBlockUi() {
  $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[level]' => 2,
    'settings[depth]' => 6,
    'settings[expand_all_items]' => TRUE,
    'settings[parent]' => 'main:',
    'settings[follow]' => TRUE,
    'settings[follow_parent]' => 'active',
    'settings[suggestion]' => 'main',
    'region' => 'primary_menu',
  ], 'Save block');
  $block = $this->blockStorage
    ->load($block_id);
  $block_settings = $block
    ->get('settings');
  $this
    ->assertSame(2, $block_settings['level']);
  $this
    ->assertSame(6, $block_settings['depth']);
  $this
    ->assertTrue($block_settings['expand_all_items']);
  $this
    ->assertSame('main:', $block_settings['parent']);
  $this
    ->assertTrue($block_settings['follow']);
  $this
    ->assertSame('active', $block_settings['follow_parent']);
  $this
    ->assertSame('main', $block_settings['suggestion']);
}