public function ConfigurationHandlerMenuLinksTestCase::testCheckModifications in Configuration Management 7.2
File
- tests/
handlers/ menu_links.test, line 95 - Tests for Configuration Management: Content Types.
Class
- ConfigurationHandlerMenuLinksTestCase
- Base class for functional tests for configuration management.
Code
public function testCheckModifications() {
// Change the path from where the configurations are loaded.
$source = drupal_get_path('module', 'configuration') . '/tests/test_configs/';
// Import the third level, import dependencies too.
$config = 'menu_link.f3aa4e71405f1a252d229e24df23187f5c0eef24';
$results = ConfigurationManagement::importToActiveStore(array(
$config,
), TRUE, FALSE, TRUE, $source);
drupal_flush_all_caches();
$imported_menu_links = db_query('SELECT COUNT(*) FROM {menu_links} WHERE menu_name = :menu_name', array(
':menu_name' => 'menu-test',
))
->fetchField();
$this
->assertTrue($imported_menu_links == 3, "The three menus were saved in the ActiveStore.");
$menu = ConfigurationManagement::createConfigurationInstance($config);
$menu::getMenuLinkByIdenfifier(NULL, TRUE);
$initial_hash = $menu
->loadFromActiveStore()
->buildHash()
->getHash();
$object = db_select('configuration_tracked', 'ct')
->fields('ct')
->condition('component', 'menu_link')
->condition('identifier', 'f3aa4e71405f1a252d229e24df23187f5c0eef24')
->execute()
->fetchObject();
$this
->assertTrue(!empty($object), 'The menu link was suscessfully tracked.');
$mlid = $menu::getMenuLinkByIdenfifier('f3aa4e71405f1a252d229e24df23187f5c0eef24');
$menu_link = menu_link_load($mlid);
$menu_link['link_title'] = 'Modified';
menu_link_save($menu_link);
$modified_hash = $menu
->loadFromActiveStore()
->buildHash()
->getHash();
$this
->assertFalse($initial_hash == $modified_hash, 'Menu link hash is not the same after modify the menu link.');
$results = ConfigurationManagement::importToActiveStore(array(
$config,
), TRUE, FALSE, TRUE, $source);
$final_hash = $menu
->loadFromActiveStore()
->buildHash()
->getHash();
$this
->assertTrue($initial_hash == $final_hash, 'Menu link hash is the same after modify the menu link.');
$menu_link = menu_link_load($mlid);
}