class MenuLinkReorderTest
Same name and namespace in other branches
- 11.x core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php \Drupal\Tests\menu_ui\Functional\MenuLinkReorderTest
- 10 core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php \Drupal\Tests\menu_ui\Functional\MenuLinkReorderTest
- 8.9.x core/modules/menu_ui/tests/src/Functional/MenuLinkReorderTest.php \Drupal\Tests\menu_ui\Functional\MenuLinkReorderTest
Reorder menu items.
@group menu_ui
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\menu_ui\Functional\MenuLinkReorderTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of MenuLinkReorderTest
File
-
core/
modules/ menu_ui/ tests/ src/ Functional/ MenuLinkReorderTest.php, line 12
Namespace
Drupal\Tests\menu_ui\FunctionalView source
class MenuLinkReorderTest extends BrowserTestBase {
/**
* An administrator user.
*
* @var \Drupal\user\UserInterface
*/
protected $administrator;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'menu_ui',
'test_page_test',
'node',
'block',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests creating, editing, deleting menu links via node form widget.
*/
public function testDefaultMenuLinkReorder() {
// Add the main menu block.
$this->drupalPlaceBlock('system_menu_block:main');
// Assert that the Home link is available.
$this->drupalGet('test-page');
$this->assertSession()
->linkExists('Home');
// The administrator user that can re-order menu links.
$this->administrator = $this->drupalCreateUser([
'administer site configuration',
'access administration pages',
'administer menu',
]);
$this->drupalLogin($this->administrator);
// Change the weight of the link to a non default value.
$edit = [
'links[menu_plugin_id:test_page_test.front_page][weight]' => -10,
];
$this->drupalGet('admin/structure/menu/manage/main');
$this->submitForm($edit, 'Save');
// The link is still there.
$this->drupalGet('test-page');
$this->assertSession()
->linkExists('Home');
// Clear all caches.
$this->drupalGet('admin/config/development/performance');
$this->submitForm([], 'Clear all caches');
// Clearing all caches should not affect the state of the menu link.
$this->drupalGet('test-page');
$this->assertSession()
->linkExists('Home');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.