menu_attach_block.test
1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Tests attaching of a core block to a menu.
*/
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() {
// Enable menu_attach_block module.
parent::setUp(array('menu', 'menu_attach_block'));
// Set up a user with privileges to add blocks.
$this->privileged_user = $this->drupalCreateUser(array('administer menu'));
$this->drupalLogin($this->privileged_user);
}
function testAttachBlock() {
// Save a new menu item with an attached block.
$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'));
// Check that the admin interface shows the block as attached.
$this->assertText(check_plain("Powered by Drupal"), t('Block attached to menu in admin interface'), 'Admin');
// Check the the block got attached to the menu.
$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'
);
}
}