menu_attach_block.test in Menu Attach Block 7
File
menu_attach_block.test
View source
<?php
class AttachBlockTestCase extends DrupalWebTestCase {
protected $privileged_user;
public static function getInfo() {
return array(
'name' => 'Attach block test case',
'description' => 'Makes sure that a block to a menu item',
'group' => 'Menu Attach Block',
);
}
public function setUp() {
parent::setUp(array(
'menu',
'menu_attach_block',
));
$this->privileged_user = $this
->drupalCreateUser(array(
'administer menu',
));
}
function testAttachBlock() {
$this
->drupalLogin($this->privileged_user);
$edit = array();
$edit['link_title'] = $this
->randomName();
$edit['link_path'] = 'admin/structure/menu/manage/main-menu/add';
$edit["menu_attach_block[name]"] = 'system|powered-by';
$this
->drupalPost($edit['link_path'], $edit, t('Save'));
$this
->assertText(check_plain("Powered by Drupal"), t('Block attached to menu in admin interface'), 'Admin');
$this
->assertPattern('|<li class="[\\w-\\d]+ attached-block|', t('Class added to Menu container li'), 'Frontend');
$this
->assertPattern('|<a href="\\/[\\?q=]?' . $edit['link_path'] . '" title="" class="attached-block">' . $edit['link_title'] . '</a>|', t('Block attached to correct link'), 'Frontend');
$edit = array();
$edit['link_title'] = $this
->randomName();
$edit['link_path'] = '<block>';
$edit["menu_attach_block[name]"] = 'system|powered-by';
$this
->drupalPost('admin/structure/menu/manage/main-menu/add', $edit, t('Save'));
$this
->assertText($edit['link_title'], 'Link to <block> (anchor without href) is displayed correctly.');
}
}