7 * Test the form permissions and switch ability of the Masquarade module.
10 class MasqueradeTestCase extends DrupalWebTestCase {
11 public static function getInfo() {
13 'name' => 'Masquerade tests',
14 'description' => 'Tests user switching with the Masquerade module.',
15 'group' => 'Masquerade',
19 public function setUp() {
20 parent::setUp('masquerade');
23 public function testMasquerade() {
25 'administer site configuration',
26 'administer permissions',
28 'administer masquerade',
30 'access user profiles',
32 'masquerade as any user',
34 $admin = $this->drupalCreateUser($admin_perms);
35 $user = $this->drupalCreateUser();
37 $this->drupalLogin($admin);
39 // Test accessing the admin form
40 $this->drupalGet('admin/config/people/masquerade');
41 $this->assertText(t('Roles that are considered "administrators" for masquerading'));
43 // Test enabling the Masquerade block
44 $this->drupalGet('admin/structure/block/manage/masquerade/masquerade/configure');
45 $this->assertText(t("'@module' block", array('@module' => 'Masquerade')));
47 'regions[bartik]' => 'content',
48 'regions[seven]' => 'content',
50 $this->drupalPost('admin/structure/block/manage/masquerade/masquerade/configure', $edit, t('Save block'));
51 $this->assertText(t('The block configuration has been saved.'));
53 // Test switch from user profile
54 $this->drupalGet("user/{$user->uid}");
55 $this->clickLink(t('Masquerade as @name', array('@name' => $user->name)));
56 $this->assertText(t('You are now masquerading as @name.', array('@name' => $user->name)));
60 $this->clickLink(t('Switch back'));
61 $this->assertText(t('You are no longer masquerading as @name and are now logged in as @admin.',
62 array('@name' => $user->name, '@admin' => $admin->name)));
64 // Test switch from masquerade block
66 'masquerade_user_field' => $user->name,
68 $this->drupalPost('', $edit, t('Go'));
69 $this->assertText(t('You are now masquerading as @name.', array('@name' => $user->name)));