You are here

function AdminMenuDynamicLinksTestCase::testNode in Administration menu 6.3

Same name and namespace in other branches
  1. 7.3 tests/admin_menu.test \AdminMenuDynamicLinksTestCase::testNode()

Tests node type links.

File

tests/admin_menu.test, line 189
Tests for the Administration menu module.

Class

AdminMenuDynamicLinksTestCase
Tests appearance, localization, and escaping of dynamic links.

Code

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/content/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/content/types/article' => 'Article',
    'admin/content/types/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.");
  }
}