Commit 7854cac4 authored by catch's avatar catch

Issue #2384653 by larowlan, swentel: Menu block - menu level and depth are not saved

parent 425a41ee
......@@ -7,6 +7,7 @@
namespace Drupal\menu_ui\Tests;
use Drupal\block\Entity\Block;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
......@@ -45,6 +46,13 @@ class MenuTest extends MenuWebTestBase {
*/
protected $authenticated_user;
/**
* Array of placed menu blocks keyed by block ID.
*
* @var array
*/
protected $blockPlacements;
/**
* A test menu.
*
......@@ -79,6 +87,7 @@ function testMenu() {
$this->menu = $this->addCustomMenu();
$this->doMenuTests();
$this->doTestMenuBlock();
$this->addInvalidMenuLink();
$this->addCustomMenuCRUD();
......@@ -213,7 +222,8 @@ function addCustomMenu() {
$this->assertText($label);
// Enable the block.
$this->drupalPlaceBlock('system_menu_block:' . $menu_name);
$block = $this->drupalPlaceBlock('system_menu_block:' . $menu_name);
$this->blockPlacements[$menu_name] = $block->id();
return Menu::load($menu_name);
}
......@@ -867,4 +877,25 @@ private function verifyAccess($response = 200) {
}
}
/**
* Tests menu block settings.
*/
protected function doTestMenuBlock() {
$menu_id = $this->menu->id();
$block_id = $this->blockPlacements[$menu_id];
$this->drupalGet('admin/structure/block/manage/' . $block_id);
$this->drupalPostForm(NULL, [
'settings[depth]' => 3,
'settings[level]' => 2,
], t('Save block'));
$block = Block::load($block_id);
$settings = $block->getPlugin()->getConfiguration();
$this->assertEqual($settings['depth'], 3);
$this->assertEqual($settings['level'], 2);
// Reset settings.
$block->getPlugin()->setConfigurationValue('depth', 0);
$block->getPlugin()->setConfigurationValue('level', 1);
$block->save();
}
}
......@@ -125,6 +125,14 @@ public static function processMenuLevelParents(&$element, FormStateInterface $fo
return $element;
}
/**
* {@inheritdoc}
*/
public function blockSubmit($form, FormStateInterface $form_state) {
$this->configuration['level'] = $form_state->getValue('level');
$this->configuration['depth'] = $form_state->getValue('depth');
}
/**
* {@inheritdoc}
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment