public function PatternsMenuTestCase::test_menu in Patterns 7.2
Same name and namespace in other branches
- 7 tests/menu/menu.test \PatternsMenuTestCase::test_menu()
File
- tests/
menu/ menu.test, line 36 - SimpleTests for the menu component of Patterns.
Class
- PatternsMenuTestCase
- @file SimpleTests for the menu component of Patterns.
Code
public function test_menu() {
module_enable(array(
'menu',
));
// TODO: move this to setUp()?
$name = 'menu-footer-links';
$title = 'Footer Links';
$description = 'Menu description.';
parent::runFile('menu_create.yaml', 'Create a menu', $this->menu_tests_dir);
//select db to verify the result is the same as the variable or not
$result = db_select('menu_custom', 'm')
->fields('m', array(
'menu_name',
'title',
'description',
))
->condition('m.menu_name', $name)
->condition('m.title', $title)
->condition('m.description', $description)
->countQuery()
->execute()
->fetchField();
$this
->assertEqual($result, 1, t('Menu was created correctly.'));
// Do menu item operations before modifying or deleting the menu link
$this
->testing_menu_item();
//menu modify
parent::runFile('menu_modify.yaml', 'Edit a menu', $this->menu_tests_dir);
$nameM = 'menu-footer-links';
$titleM = 'Footer Links';
$descriptionM = 'Menu description changed.';
$result = db_select('menu_custom', 'm')
->fields('m', array(
'menu_name',
'title',
'description',
))
->condition('m.menu_name', $nameM)
->condition('m.title', $titleM)
->condition('m.description', $descriptionM)
->execute()
->fetchAll();
$this
->assertEqual(count($result), 1, t('Modified menu item found.'));
//Menu delete use nameM to delete verfication
parent::runFile('menu_delete.yaml', 'Delete a menu', $this->menu_tests_dir);
$result = db_select('menu_custom', 'm')
->fields('m', array(
'menu_name',
'title',
'description',
))
->condition('m.menu_name', $nameM)
->condition('m.title', $titleM)
->condition('m.description', $descriptionM)
->countQuery()
->execute()
->fetchField();
$this
->assertEqual($result, 0, 'Menu link was deleted correctly.');
}