You are here

public function BootstrapMenuItemsBasicTest::assertMenuLink in Bootstrap menu items 8.3

Same name and namespace in other branches
  1. 7.3 bootstrap_menu_items.test \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 src/Tests/BootstrapMenuItemsBasicTest.php
CORE menu module clone.
BootstrapMenuItemsBasicTest::testBootstrapMenuItemsMenuTests in src/Tests/BootstrapMenuItemsBasicTest.php
Test custom menu items.

File

src/Tests/BootstrapMenuItemsBasicTest.php, 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,
    )));
  }
}