public function AdminMenuCustomizedTestCase::testCustomDisabled in Administration menu 7.3
Test disabled custom links.
File
- tests/
admin_menu.test, line 484 - Tests for the Administration menu module.
Class
- AdminMenuCustomizedTestCase
- Tests customized menu links.
Code
public function testCustomDisabled() {
$type = $this
->drupalCreateContentType();
$node = $this
->drupalCreateNode(array(
'type' => $type->type,
));
$text = $this
->randomName();
$xpath = $this
->buildXPathQuery('//div[@id=:id]//a[contains(text(), :text)]', array(
':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 = array(
'link_path' => 'node/' . $node->nid,
'link_title' => $text,
'parent' => 'management:' . $this
->queryMlidByPath('admin'),
);
$this
->drupalPost('admin/structure/menu/manage/management/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 = array(
'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.');
}