function AdminMenuLinksTestCase::testLinkContents in Administration menu 6
Test link contents.
File
- tests/
admin_menu.test, line 121 - Administration menu functionality tests.
Class
- AdminMenuLinksTestCase
- Test contained links in administration menu.
Code
function testLinkContents() {
// Create a content-type with special characters.
$info = array(
'type' => 'special',
'name' => 'Cool & Special',
'module' => 'node',
'description' => '',
);
$info = (object) _node_type_set_defaults($info);
node_type_save($info);
$this
->drupalPost('admin/settings/performance', array(), t('Clear cached data'));
// Fetch a page.
$this
->drupalGet('node');
$this
->assertRaw('<div id="admin-menu"', t('Administration menu is displayed.'));
// Verify that proper links are displayed.
// We are explicitly NOT using t() here, since the purpose is to test our
// custom link titles and 't' option.
$links = array(
url('admin/content/node-type/page') => strtr('Edit !content-type', array(
'!content-type' => t('Page'),
)),
url('admin/content/node-type/special') => strtr('Edit !content-type', array(
'!content-type' => t('Cool & Special'),
)),
);
foreach ($links as $url => $title) {
$this
->assertFieldByXPath('//div[@id="admin-menu"]//a[@href="' . $url . '"]', $title, t('!link-title content-type link found.', array(
'!link-title' => $title,
)));
}
$links = array(
url('node/add/page') => t('Page'),
url('node/add/special') => t('Cool & Special'),
);
foreach ($links as $url => $title) {
$this
->assertFieldByXPath('//div[@id="admin-menu"]//a[@href="' . $url . '"]', $title, t('Create content » !link-title link found.', array(
'!link-title' => $title,
)));
}
}