-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmasquerade.test
73 lines (61 loc) · 2.31 KB
/
masquerade.test
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @file
* masquerade.test
*
* Test the form permissions and switch ability of the Masquarade module.
*/
class MasqueradeTestCase extends BackdropWebTestCase {
public static function getInfo() {
return array(
'name' => 'Masquerade tests',
'description' => 'Tests user switching with the Masquerade module.',
'group' => 'Masquerade',
);
}
public function setUp() {
parent::setUp('masquerade');
}
public function testMasquerade() {
$admin_perms = array(
'administer site configuration',
'administer permissions',
'administer blocks',
'administer masquerade',
'administer users',
'access user profiles',
'masquerade as user',
'masquerade as any user',
);
$admin = $this->backdropCreateUser($admin_perms);
$user = $this->backdropCreateUser();
$this->backdropLogin($admin);
// Test accessing the admin form
$this->backdropGet('admin/config/people/masquerade');
$this->assertText(t('Roles that are considered "administrators" for masquerading'));
// Test enabling the Masquerade block
$this->backdropGet('admin/structure/block/manage/masquerade/masquerade/configure');
$this->assertText(t("'@module' block", array('@module' => 'Masquerade')));
$edit = array(
'regions[bartik]' => 'content',
'regions[seven]' => 'content',
);
$this->backdropPost('admin/structure/block/manage/masquerade/masquerade/configure', $edit, t('Save block'));
$this->assertText(t('The block configuration has been saved.'));
// Test switch from user profile
$this->backdropGet("user/{$user->uid}");
$this->clickLink(t('Masquerade as @name', array('@name' => $user->name)));
$this->assertText(t('You are now masquerading as @name.', array('@name' => $user->name)));
// Test unswitch
$this->backdropGet('');
$this->clickLink(t('Switch back'));
$this->assertText(t('You are no longer masquerading as @name and are now logged in as @admin.',
array('@name' => $user->name, '@admin' => $admin->name)));
// Test switch from masquerade block
$edit = array(
'masquerade_user_field' => $user->name,
);
$this->backdropPost('', $edit, t('Go'));
$this->assertText(t('You are now masquerading as @name.', array('@name' => $user->name)));
}
}