class MemCacheRealWorldCase in Zircon Profile 8
Same name and namespace in other branches
- 8.0 modules/memcache/tests/memcache.test \MemCacheRealWorldCase
Test some real world cache scenarios with default modules.
Please make sure you've set the proper memcache settings in the settings.php. Looks like I've not chance to change the cache settings to what's needed by this test.
Hierarchy
- class \MemCacheRealWorldCase extends \DrupalWebTestCase
Expanded class hierarchy of MemCacheRealWorldCase
File
- modules/
memcache/ tests/ memcache.test, line 499
View source
class MemCacheRealWorldCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Real world cache tests',
'description' => 'Test some real world cache scenarios.',
'group' => 'Memcache',
);
}
function setUp() {
parent::setUp('menu');
}
/**
* Test if the menu module caching acts as expected.
*
* The menu module clears the affected menu if an menu item is changed using
* wildcards.
*/
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;
}
}
}
/**
* Adds a menu link.
*
* @see MenuTestCase::addMenuLink()
*/
function addMenuLink($plid = 0, $link = '<front>', $menu_name = 'main-menu') {
// View add menu link page.
$this
->drupalGet("admin/structure/menu/manage/{$menu_name}/add");
$this
->assertResponse(200);
$title = '!OriginalLink_' . $this
->randomName(16);
$edit = array(
'link_path' => $link,
'link_title' => $title,
'description' => '',
'enabled' => TRUE,
// Use this to disable the menu and test.
'expanded' => TRUE,
// Setting this to true should test whether it works when we do the std_user tests.
'parent' => $menu_name . ':' . $plid,
'weight' => '0',
);
// Add menu link.
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertResponse(200);
// Unlike most other modules, there is no confirmation message displayed.
$this
->assertText($title, 'Menu link was added');
$item = db_query('SELECT * FROM {menu_links} WHERE link_title = :title', array(
':title' => $title,
))
->fetchAssoc();
return $item;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MemCacheRealWorldCase:: |
function | Adds a menu link. | ||
MemCacheRealWorldCase:: |
public static | function | ||
MemCacheRealWorldCase:: |
function | |||
MemCacheRealWorldCase:: |
function | Test if the menu module caching acts as expected. |