public function AdminMenuDynamicLinksTestCase::testNode in Administration menu 7.3
Same name and namespace in other branches
- 6.3 tests/admin_menu.test \AdminMenuDynamicLinksTestCase::testNode()
Tests node type links.
File
- tests/
admin_menu.test, line 296 - Tests for the Administration menu module.
Class
- AdminMenuDynamicLinksTestCase
- Tests appearance, localization, and escaping of dynamic links.
Code
public function testNode() {
$type = $this
->drupalCreateContentType(array(
'type' => 'article',
'name' => 'Article',
));
// Create a content-type with special characters.
$type = $this
->drupalCreateContentType(array(
'type' => 'special',
'name' => 'Cool & Special',
));
$permissions = $this->basePermissions + array(
'administer content types',
'create article content',
'create special content',
);
$this->admin_user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->admin_user);
// Verify that dynamic links are displayed.
$this
->drupalGet('');
$this
->assertElementByXPath('//div[@id="admin-menu"]', array(), t('Administration menu found.'));
$this
->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path)]', array(
':path' => 'admin/structure/types',
), "Structure » Content types link found.");
// Verify link title output escaping.
$this
->assertNoRaw('Cool & Special');
$this
->assertRaw(check_plain('Cool & Special'));
// Verify Manage content type links.
$links = array(
'admin/structure/types/manage/article' => 'Article',
'admin/structure/types/manage/special' => 'Cool & Special',
);
foreach ($links as $path => $title) {
$this
->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(
':path' => $path,
':title' => $title,
), "Structure » Content types » {$title} link found.");
}
// Verify Add content links.
$links = array(
'node/add/article' => 'Article',
'node/add/special' => 'Cool & Special',
);
foreach ($links as $path => $title) {
$this
->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', array(
':path' => $path,
':title' => $title,
), "Add content » {$title} link found.");
}
}