You are here

public function BootstrapMenuItemsBasicTest::assertMenuLink in Bootstrap menu items 7.3

Same name and namespace in other branches
  1. 8.3 src/Tests/BootstrapMenuItemsBasicTest.php \BootstrapMenuItemsBasicTest::assertMenuLink()

CORE menu module clone.

Fetch the menu item from the database and compare it to the specified array.

Parameters

int $mlid: Menu item id.

array $expected_item: Array containing properties to verify.

2 calls to BootstrapMenuItemsBasicTest::assertMenuLink()
BootstrapMenuItemsBasicTest::addMenuLink in ./bootstrap_menu_items.test
CORE menu module clone.
BootstrapMenuItemsBasicTest::testBootstrapMenuItemsMenuTests in ./bootstrap_menu_items.test
Test custom menu items.

File

./bootstrap_menu_items.test, line 177
Test file for Bootstrap menu items module.

Class

BootstrapMenuItemsBasicTest
Test basic functionality of Bootstrap menu items module.

Code

public function assertMenuLink($mlid, array $expected_item) {

  // Retrieve menu link.
  $item = db_query('SELECT * FROM {menu_links} WHERE mlid = :mlid', array(
    ':mlid' => $mlid,
  ))
    ->fetchAssoc();
  $options = unserialize($item['options']);
  if (!empty($options['query'])) {
    $item['link_path'] .= '?' . drupal_http_build_query($options['query']);
  }
  if (!empty($options['fragment'])) {
    $item['link_path'] .= '#' . $options['fragment'];
  }
  foreach ($expected_item as $key => $value) {
    $this
      ->assertEqual($item[$key], $value, format_string('Parameter %key had expected value.', array(
      '%key' => $key,
    )));
  }
}