You are here

public function TaxonomyMenuWebTestCase::assertMenuLink in Taxonomy menu 8

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

Parameters

$mlid: The identifier of a menu link.

$expected_item: An array containing properties to verify.

2 calls to TaxonomyMenuWebTestCase::assertMenuLink()
TaxonomyMenuConfigurationTest::testTaxonomyMenuCountNodes in lib/Drupal/taxonomy_menu/Tests/TaxonomyMenuConfigurationTest.php
Tests Taxonommy Menu "Node count" option.
TaxonomyMenuConfigurationTest::testTaxonomyMenuHideEmptyTerms in lib/Drupal/taxonomy_menu/Tests/TaxonomyMenuConfigurationTest.php
Tests Taxonommy Menu "Hide Empty terms" option.

File

lib/Drupal/taxonomy_menu/Tests/TaxonomyMenuWebTestCase.php, line 105
Definition of Drupal\taxonomy_menu\Tests\TaxonomyMenuWebTestCase.

Class

TaxonomyMenuWebTestCase
Abstract class for Taxonomy menu testing. All Taxonomy menu tests should extend this class.

Namespace

Drupal\taxonomy_menu\Tests

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, t('Parameter %key had expected value.', array(
      '%key' => $key,
    )));
  }
}