You are here

function MenuTestCase::testMenuQueryAndFragment in Drupal 7

Add and remove a menu link with a query string and fragment.

File

modules/menu/menu.test, line 280
Tests for menu.module.

Class

MenuTestCase
@file Tests for menu.module.

Code

function testMenuQueryAndFragment() {
  $this
    ->drupalLogin($this->big_user);

  // Make a path with query and fragment on.
  $path = 'node?arg1=value1&arg2=value2';
  $item = $this
    ->addMenuLink(0, $path);
  $this
    ->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
  $this
    ->assertFieldByName('link_path', $path, 'Path is found with both query and fragment.');

  // Now change the path to something without query and fragment.
  $path = 'node';
  $this
    ->drupalPost('admin/structure/menu/item/' . $item['mlid'] . '/edit', array(
    'link_path' => $path,
  ), t('Save'));
  $this
    ->drupalGet('admin/structure/menu/item/' . $item['mlid'] . '/edit');
  $this
    ->assertFieldByName('link_path', $path, 'Path no longer has query or fragment.');
}