Skip to content
Snippets Groups Projects
Commit f37bc920 authored by David Suissa's avatar David Suissa Committed by Jakob P
Browse files

Issue #3466125 by dydave, japerry, teknocat: [AdminToolbarSettingsForm] Fix...

Issue #3466125 by dydave, japerry, teknocat: [AdminToolbarSettingsForm] Fix Fatal Error: Call to undefined method Drupal\Core\Menu\MenuLinkManager::invalidateAll()
parent 14ed61f7
No related branches found
No related tags found
1 merge request!94Issue #3466125 by DYdave: Fixed fatal error 'Call to undefined method...
Pipeline #275082 canceled
......@@ -32,8 +32,8 @@ class AdminToolbarToolsSettingsForm extends ConfigFormBase {
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->cacheMenu = $container->get('plugin.manager.menu.link');
$instance->menuLinkManager = $container->get('cache.menu');
$instance->cacheMenu = $container->get('cache.menu');
$instance->menuLinkManager = $container->get('plugin.manager.menu.link');
return $instance;
}
......
......@@ -32,8 +32,8 @@ class AdminToolbarSettingsForm extends ConfigFormBase {
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->cacheMenu = $container->get('plugin.manager.menu.link');
$instance->menuLinkManager = $container->get('cache.menu');
$instance->cacheMenu = $container->get('cache.menu');
$instance->menuLinkManager = $container->get('plugin.manager.menu.link');
return $instance;
}
......
<?php
namespace Drupal\Tests\admin_toolbar\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Test the Admin Toolbar settings form.
*
* @group admin_toolbar
*/
class AdminToolbarSettingsFormTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = [
'admin_toolbar',
];
/**
* A user with access to the Admin Toolbar settings form permission.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$permissions = [
'access toolbar',
'access administration pages',
'administer site configuration',
];
$this->adminUser = $this->drupalCreateUser($permissions);
}
/**
* Test backend admin toolbar settings form fields and submission.
*/
public function testAdminToolbarSettingsForm(): void {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this->assertSession();
// Log in as an admin user to test admin pages.
$this->drupalLogin($this->adminUser);
// Test the 'Admin Toolbar settings' page form submission and fields.
$this->drupalGet('admin/config/user-interface/admin-toolbar');
$this->submitForm([], 'Save configuration');
$assert->pageTextContains('The configuration options have been saved.');
// Test 'Menu depth' for the Admin Toolbar settings form, under:
// Configuration > User interface > Admin Toolbar.
// Default value '4': the menu should be displayed as level 3.
$assert->elementExists('xpath', '//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[@class="menu-item"]//a[contains(@href, "/admin/config/user-interface/admin-toolbar") and contains(.,"Admin Toolbar")]');
// Set the 'Menu depth' to '2' and save the form.
$edit = [
'menu_depth' => '2',
];
$this->submitForm($edit, 'Save configuration');
$assert->pageTextContains('The configuration options have been saved.');
// Check the menu item 'Admin Toolbar' is not displayed.
$assert->elementNotExists('xpath', '//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[@class="menu-item"]//a[contains(@href, "/admin/config/user-interface/admin-toolbar") and contains(.,"Admin Toolbar")]');
// Check the menu item 'User interface' does not have a child 'ul'.
$assert->elementNotExists('xpath', '//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item")]//ul');
// Check the menu item 'User interface' contains a link but not a menu item.
$assert->elementExists('xpath', '//div[@class="toolbar-menu-administration"]//ul[contains(@class, "toolbar-menu")]//li[contains(@class, "menu-item")]//ul[@class="toolbar-menu"]//li[contains(@class, "menu-item") and contains(a, .) and not(contains(ul, .))]');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment