1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* masquerade.test
|
6
|
*
|
7
|
* Test the form permissions and switch ability of the Masquarade module.
|
8
|
*/
|
9
|
|
10
|
class MasqueradeTestCase extends DrupalWebTestCase {
|
11
|
public static function getInfo() {
|
12
|
return array(
|
13
|
'name' => 'Masquerade tests',
|
14
|
'description' => 'Tests user switching with the Masquerade module.',
|
15
|
'group' => 'Masquerade',
|
16
|
);
|
17
|
}
|
18
|
|
19
|
public function setUp() {
|
20
|
parent::setUp('masquerade');
|
21
|
}
|
22
|
|
23
|
public function testMasquerade() {
|
24
|
$admin_perms = array(
|
25
|
'administer site configuration',
|
26
|
'administer permissions',
|
27
|
'masquerade as user',
|
28
|
);
|
29
|
$admin = $this->drupalCreateUser($admin_perms);
|
30
|
$user = $this->drupalCreateUser();
|
31
|
|
32
|
$this->drupalLogin($admin);
|
33
|
|
34
|
//test admin form
|
35
|
$this->drupalGet('admin/config/development/masquerade');
|
36
|
|
37
|
//test switch
|
38
|
$this->drupalGet('masquerade/switch/' . $user->uid);
|
39
|
$this->assertText('Now masquerading as ' . $user->name);
|
40
|
|
41
|
//test unswitch
|
42
|
$this->drupalGet('masquerade/unswitch');
|
43
|
$this->assertText('No longer masquerading as ' . $user->name);
|
44
|
}
|
45
|
|
46
|
}
|
47
|
|