1 menu.test | MenuTestCase::assertMenuLink($mlid, array $expected_item) |
Fetch the menu item from the database and compare it to the specified array.
Parameters
$mlid: Menu item id.
$item: Array containing properties to verify.
File
- core/
modules/ menu/ tests/ menu.test, line 560 - Tests for menu.module.
Class
Code
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'] .= '?' . backdrop_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 value %actual, expected %expected for the %path path.', array('%key' => $key, '%path' => $item['link_path'], '%actual' => $item[$key], '%expected' => $value)));
}
}