You are here

function MenuImportTestCase::validateMenu in Menu Export/Import 7

1 call to MenuImportTestCase::validateMenu()
MenuImportTestCase::testBasicFeatures in ./menu_import.test
Verifies basic functionality by running two imports - the first creates menu links and new nodes referenced by them, the other one reorders existing menu items searching for existing content by title.

File

./menu_import.test, line 207
Test file for menu_import module.

Class

MenuImportTestCase
Functionality tests for menu_import module.

Code

function validateMenu($reference, &$actual) {

  //global $reference, $hidden
  foreach ($actual as $id => $menu_item) {
    list($some_id, $page, $page_id, $mlid) = explode(' ', $id);
    $this
      ->assertEqual($menu_item['link']['link_title'], "{$page} {$page_id}");
    $this
      ->assertEqual(strpos($menu_item['link']['link_path'], 'node/'), 0);

    // Root page
    if (isset($reference[$page_id])) {
      $this
        ->assertEqual(count($menu_item['below']), count($reference[$page_id]));
      $this
        ->validateMenu($reference[$page_id], $menu_item['below']);
    }
    elseif (!in_array($page_id, $reference)) {
      $this
        ->fail('Imported structure doesn\'t match the expected one.');
      return;
    }

    // Test if hidden.
    if (in_array($page_id, $this->validate_hidden)) {
      $this
        ->assertEqual($menu_item['link']['hidden'], 1);
    }

    // Test if expanded.
    if (in_array($page_id, $this->validate_expanded)) {
      $this
        ->assertEqual($menu_item['link']['expanded'], 1);
    }
  }
}