You are here

function MemCacheRealWorldCase::testMenu in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/tests/memcache.test \MemCacheRealWorldCase::testMenu()

Test if the menu module caching acts as expected.

The menu module clears the affected menu if an menu item is changed using wildcards.

File

modules/memcache/tests/memcache.test, line 519

Class

MemCacheRealWorldCase
Test some real world cache scenarios with default modules.

Code

function testMenu() {

  // Create and login user.
  $account = $this
    ->drupalCreateUser(array(
    'access administration pages',
    'administer blocks',
    'administer menu',
    'create article content',
  ));
  $this
    ->drupalLogin($account);

  // Add Menu Link to test with
  $item = $this
    ->addMenuLink();
  $original_title = $item['link_title'];

  // Check if menu link is displayed.
  $this
    ->drupalGet('');
  $this
    ->assertText($original_title, 'Menu item displayed in frontend');

  // Change menu item multiple times and check if the change is reflected.
  for ($i = 0; $i < 3; $i++) {

    // Edit menu link.
    $edit = array();
    $edit['link_title'] = $this
      ->randomName(16);
    $this
      ->drupalPost("admin/structure/menu/item/{$item['mlid']}/edit", $edit, t('Save'));
    if (!$this
      ->assertResponse(200)) {

      // One fail is enough.
      break;
    }

    // Verify edited menu link.
    if (!$this
      ->drupalGet('admin/structure/menu/manage/' . $item['menu_name'])) {

      // One fail is enough.
      break;
    }
    $this
      ->assertText($edit['link_title'], 'Menu link was edited');
    $this
      ->drupalGet('');
    if (!$this
      ->assertText($edit['link_title'], 'Change is reflected in frontend')) {

      // One fail is enough.
      break;
    }
  }
}