Skip to content

Commit 71a8246

Browse files
committed
more tests
1 parent 7b6a731 commit 71a8246

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/functional/ViewAsUserTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,23 @@ public function testViewAsSelf()
6161
{
6262
$this->_testViewAsUser(getAdminUser(), getAdminUser());
6363
}
64+
65+
public function testNonAdminViewAsAdmin()
66+
{
67+
global $USER;
68+
switchUser(...getAdminUser());
69+
$adminUid = $USER->getUID();
70+
$this->assertTrue($USER->isAdmin());
71+
switchUser(...getNormalUser());
72+
try {
73+
http_post(
74+
__DIR__ . "/../../webroot/admin/user-mgmt.php",
75+
[
76+
"form_name" => "viewAsUser",
77+
"uid" => $adminUid,
78+
],
79+
);
80+
} catch (PhpUnitNoDieException) {}
81+
$this->assertArrayNotHasKey("viewUser", $_SESSION);
82+
}
6483
}

0 commit comments

Comments
 (0)