public function AckMenuAccessTest::testEventHooks in Access Control Kit 7
Test that the module responds appropriately to events that affect the map.
File
- ack_menu/
ack_menu.test, line 787 - Tests for the ACK menu module.
Class
- AckMenuAccessTest
- Tests the menu access functions.
Code
public function testEventHooks() {
$this
->setUpScheme();
$scheme = access_scheme_machine_name_load($this->schemeMachineName);
// Create two mapped links.
for ($i = 0; $i < 2; $i++) {
$edit = array(
'link_title' => $this
->randomName(),
'link_path' => 'node',
);
$this
->drupalPost('ack_menu/manage/' . $scheme->machine_name . '/' . $this->ackUser->uid . '/add', $edit, 'Save');
}
// Confirm that mappings are deleted when links are deleted.
$links = ack_menu_realm_links($scheme, $this->ackUser->uid, NULL, TRUE);
$this
->assertEqual(count($links), 2, 'Two mappings found.');
$link = reset($links);
menu_link_delete($link['mlid']);
$this
->assertFalse(menu_link_load($link['mlid']), 'One link deleted.');
$links = ack_menu_realm_links($scheme, $this->ackUser->uid, NULL, TRUE);
$this
->assertEqual(count($links), 1, 'One mapping remains.');
// Create a second scheme with a mapped link.
$this
->setUpScheme();
$new_scheme = access_scheme_machine_name_load($this->schemeMachineName);
$edit = array(
'link_title' => $this
->randomName(),
'link_path' => 'node',
);
$this
->drupalPost('ack_menu/manage/' . $new_scheme->machine_name . '/' . $this->ackUser->uid . '/add', $edit, 'Save');
// Confirm that mappings are deleted when schemes are deleted.
$new_links = ack_menu_realm_links($new_scheme, $this->ackUser->uid, NULL, TRUE);
$this
->assertEqual(count($links) + count($new_links), 2, 'Two mappings found.');
access_scheme_delete($new_scheme->sid);
$this
->assertFalse(access_scheme_load($new_scheme->sid), 'One scheme deleted.');
$new_links = ack_menu_realm_links($new_scheme, $this->ackUser->uid, NULL, TRUE);
$this
->assertEqual(count($links) + count($new_links), 1, 'One mapping remains.');
}