function MenuNodeAPIBasicTestCase::testMenuNodeAPI in Menu Node API 7
Tests for basic internal module functions.
Here we check that the install/uninstall routine works, and then we test various node and menu link saves.
File
- tests/
menu_node.test, line 154 - Simpletest for Menu Node API.
Class
- MenuNodeAPIBasicTestCase
- Inherit methods from the parent class and test core module.
Code
function testMenuNodeAPI() {
// Create some nodes.
$this
->menuNodeAPICreateNodes(10, 3);
// Create some non-node menu items.
$this
->menuNodeAPICreateItems(3);
// Check that we have the expected record count.
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 3, t('Found the correct row count in {menu_node}.'));
// Truncate the table by running menu_node_disable().
module_load_install('menu_node');
menu_node_disable();
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 0, t('Module successfully disabled. No records in {menu_node}.'));
// Rebuild the table by running menu_node_enable().
menu_node_enable();
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 3, t('Module successfully enabled. Found the correct row count in {menu_node}.'));
// Delete a node that is in the menu.
$this
->menuNodeAPIDeleteNode(TRUE);
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 2, t('Deleted node from the menu. Found the correct row count in {menu_node}.'));
// Delete a node that is not in the menu.
$this
->menuNodeAPIDeleteNode(FALSE);
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 2, t('Deleted node not in the menu. Found the correct row count in {menu_node}.'));
// Delete a link that is a node.
$this
->menuNodeAPIDeleteLink(TRUE);
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 1, t('Deleted node link from the menu. Found the correct row count in {menu_node}.'));
// Delete a link that is not a node.
$this
->menuNodeAPIDeleteLink(FALSE);
$count = db_query("SELECT COUNT(*) FROM {menu_node}")
->fetchField();
$this
->assertTrue($count == 1, t('Deleted non-node link from the menu. Found the correct row count in {menu_node}.'));
}