function AdminMenuCustomizedTest::testCustomDisabled in Administration menu 8.3
Test disabled custom links.
File
- lib/
Drupal/ admin_menu/ Tests/ AdminMenuCustomizedTest.php, line 29
Class
- AdminMenuCustomizedTest
- Tests customized menu links.
Namespace
Drupal\admin_menu\TestsCode
function testCustomDisabled() {
$type = $this
->drupalCreateContentType();
$node = $this
->drupalCreateNode([
'type' => $type->type,
]);
$text = $this
->randomName();
$xpath = $this
->buildXPathQuery('//div[@id=:id]//a[contains(text(), :text)]', [
':id' => 'admin-menu',
':text' => $text,
]);
// Verify that the link does not appear in the menu.
$this
->drupalGet('node');
$elements = $this
->xpath($xpath);
$this
->assertFalse($elements, 'Custom link not found.');
// Add a custom link to the node to the menu.
$edit = [
'link_path' => 'node/' . $node->nid,
'link_title' => $text,
'parent' => 'admin:' . $this
->queryMlidByPath('admin'),
];
$this
->drupalPost('admin/structure/menu/manage/admin/add', $edit, t('Save'));
// Verify that the link appears in the menu.
$this
->drupalGet('node');
$elements = $this
->xpath($xpath);
$this
->assertTrue($elements, 'Custom link found.');
// Disable the link.
$edit = [
'enabled' => FALSE,
];
$this
->drupalPost('admin/structure/menu/item/' . $this
->queryMlidByPath('node/' . $node->nid) . '/edit', $edit, t('Save'));
// Verify that the disabled link does not appear in the menu.
$this
->drupalGet('node');
$elements = $this
->xpath($xpath);
$this
->assertFalse($elements, 'Disabled custom link not found.');
}