1 menu_language.test protected MenuLanguageTestCase::validateParentOptions(array $current_options, $langcode, $skip_title = NULL)

Verify that the items provided in the select list are usable as parents.

Parameters

array $current_options: The parent options contained in the select list.

string $langcode: The language code of the current item, could be menu item or node.

string $skip_title: Optional, the menu item title to exclude from result.

Return value

bool: Whether the array matches the database result for that language code.

File

core/modules/menu/tests/menu_language.test, line 50
Tests for menu.module.

Class

MenuLanguageTestCase
Functional tests for multilingual menu items.

Code

protected function validateParentOptions(array $current_options, $langcode, $skip_title = NULL) {
  if ($langcode == LANGUAGE_NONE) {
    $langcodes = $this->langcodes;
  }
  else {
    $langcodes = array($langcode, LANGUAGE_NONE);
  }

  // Get all items from database, that should be available.
  $query = db_select('menu_links', 'ml')
    ->fields('ml', array('mlid', 'link_title'))
    ->condition('menu_name', 'main-menu')
    ->condition('langcode', $langcodes, 'IN');
  if (!empty($skip_title)) {
    $query->condition('link_title', $skip_title, '!=');
  }
  $result = $query->execute()->fetchAllAssoc('mlid');
  $valid_mlids = array_keys($result);
  sort($valid_mlids);
  sort($current_options);

  if ($current_options == $valid_mlids) {
    return TRUE;
  }
  return FALSE;
}