You are here

public function ConfigurationHandlerPageManagerTestCase::testCheckModifications in Configuration Management 7.2

File

tests/handlers/page_manager.test, line 163
Tests for Configuration Management: Page Manager Components.

Class

ConfigurationHandlerPageManagerTestCase
Base class for functional tests for configuration management.

Code

public function testCheckModifications() {

  // Change the path from where the configurations are loaded.
  ConfigurationManagement::setStream(drupal_get_path('module', 'configuration') . '/tests/test_configs/');
  $config = 'menu_link.menu-configuration-test-menu.218.Top_Level_link_1';
  $results = ConfigurationManagement::importToActiveStore(array(
    $config,
  ), TRUE, TRUE, TRUE);
  $alltracked = ConfigurationManagement::trackedConfigurations();
  $trackedmenus = array();
  foreach ($alltracked['menu'] as $identifier => $hash) {
    $trackedmenus[] = 'menu.' . $identifier;
  }
  foreach ($alltracked['menu_link'] as $identifier => $hash) {
    $trackedmenus[] = 'menu_link.' . $identifier;
  }
  foreach ($results
    ->getInfo('imported') as $component) {
    $this
      ->assertTrue(in_array($component, $trackedmenus), "The component {$component} was suscessfully tracked.");
  }
  $original_menu_link = menu_link_load('218');
  $original_menu = menu_load('menu-configuration-test-menu');
  $web_user = $this
    ->drupalCreateUser(array(
    'administer menu',
  ));
  $this
    ->drupalLogin($web_user);
  $mlid = $original_menu_link['mlid'];
  $new_menulink_title = $original_menu_link['link_title'] . '(edited)';

  // Edit menu link.
  $edit = array();
  $edit['link_title'] = $new_menulink_title;
  $this
    ->drupalPost("admin/structure/menu/item/{$mlid}/edit", $edit, t('Save'));
  $this
    ->assertResponse(200);

  // Edit the menu.
  $edit = array();
  $new_menu_title = $original_menu['title'] . '(edited)';
  $edit['title'] = $new_menu_title;
  $edit['menu_name'] = $original_menu['menu_name'];
  $edit['description'] = $original_menu['description'];
  menu_save($edit);
  $this
    ->drupalGet('admin/structure/menu/manage/' . $original_menu['menu_name'] . '/edit');
  $this
    ->assertRaw($new_menu_title, t('Custom menu was edited.'));
  $modified_menu_link = menu_link_load('218');
  $modified_menu = menu_load('menu-configuration-test-menu');
  $this
    ->assertTrue($modified_menu_link['link_title'] == $new_menulink_title, 'The menu link was modified');
  $this
    ->assertTrue($modified_menu['title'] == $new_menu_title, 'The menu was modified');
  $results = ConfigurationManagement::revertActiveStore(array(
    'menu_link.menu-configuration-test-menu.218.Top_Level_link_1',
  ), TRUE, TRUE);
  $modified_menu_link = menu_link_load('218');
  $modified_menu = menu_load('menu-configuration-test-menu');
  $this
    ->assertTrue($modified_menu_link['link_title'] == $original_menu_link['link_title'], 'Menu Link reverted');
  $this
    ->assertTrue($modified_menu['title'] == $original_menu['title'], 'Menu reverted');
}