public function AckMenuAccessTest::setUpMenu in Access Control Kit 7
Utility function to set up a menu link access test.
2 calls to AckMenuAccessTest::setUpMenu()
- AckMenuAccessTest::testAckMenuUI in ack_menu/
ack_menu.test - Test the menu management UI.
- AckMenuAccessTest::testNodeMenuUI in ack_menu/
ack_menu.test - Test controlling access to the node menu options.
File
- ack_menu/
ack_menu.test, line 150 - Tests for the ACK menu module.
Class
- AckMenuAccessTest
- Tests the menu access functions.
Code
public function setUpMenu() {
$this
->setUpScheme();
// Create the test menu items.
$this->items = array();
$keys = array(
'not mapped',
'mapped top link',
'mapped child link',
'not mapped child link',
'no access child link',
'no access grandchild link',
'no access top link',
'mapped child link with no access parent',
);
foreach ($keys as $key) {
$item = array(
'link_path' => 'node',
'link_title' => $this
->randomName(),
'menu_name' => 'navigation',
);
switch ($key) {
case 'mapped child link':
case 'not mapped child link':
case 'no access child link':
$item['plid'] = $this->items['mapped top link']['mlid'];
break;
case 'no access grandchild link':
$item['plid'] = $this->items['no access child link']['mlid'];
break;
case 'mapped child link with no access parent':
$item['plid'] = $this->items['no access top link']['mlid'];
break;
default:
$item['plid'] = NULL;
}
$mlid = menu_link_save($item);
$this->items[$key] = menu_link_load($mlid);
}
menu_cache_clear_all();
// Map the menu items.
$element = 'AckMenuMap[' . $this->schemeMachineName . ']';
$edit = array(
$element => $this->ackUser->uid,
);
$this
->drupalPost('admin/structure/menu/item/' . $this->items['mapped top link']['mlid'] . '/edit', $edit, 'Save');
$edit = array(
$element => $this->ackAdmin->uid,
);
$this
->drupalPost('admin/structure/menu/item/' . $this->items['mapped child link']['mlid'] . '/edit', $edit, 'Save');
$this
->drupalPost('admin/structure/menu/item/' . $this->items['mapped child link with no access parent']['mlid'] . '/edit', $edit, 'Save');
$edit = array(
$element => $this->noAccessUser->uid,
);
$this
->drupalPost('admin/structure/menu/item/' . $this->items['no access top link']['mlid'] . '/edit', $edit, 'Save');
$this
->drupalPost('admin/structure/menu/item/' . $this->items['no access child link']['mlid'] . '/edit', $edit, 'Save');
}