diff --git a/tests/php/Control/ControllerTest.php b/tests/php/Control/ControllerTest.php index f0595bdf3..218506d05 100644 --- a/tests/php/Control/ControllerTest.php +++ b/tests/php/Control/ControllerTest.php @@ -179,15 +179,15 @@ class ControllerTest extends FunctionalTest 'Access denied on action with $allowed_actions on defining controller, ' . 'if action is not a method but rather a template discovered by naming convention' ); - Security::setCurrentUser($adminUser); - $response = $this->get("AccessSecuredController/templateaction"); - $this->assertEquals( - 200, - $response->getStatusCode(), - 'Access granted for logged in admin on action with $allowed_actions on defining controller, ' . 'if action is not a method but rather a template discovered by naming convention' - ); + Member::actAs($adminUser, function () { + $response = $this->get("AccessSecuredController/templateaction"); + $this->assertEquals( + 200, + $response->getStatusCode(), + 'Access granted for logged in admin on action with $allowed_actions on defining controller, ' . 'if action is not a method but rather a template discovered by naming convention' + ); + }); - Security::setCurrentUser(null); $response = $this->get("AccessSecuredController/adminonly"); $this->assertEquals( 403, @@ -209,15 +209,15 @@ class ControllerTest extends FunctionalTest "Access denied to protected method even if its listed in allowed_actions" ); - Security::setCurrentUser($adminUser); - $response = $this->get("AccessSecuredController/adminonly"); - $this->assertEquals( - 200, - $response->getStatusCode(), - "Permission codes are respected when set in \$allowed_actions" - ); + Member::actAs($adminUser, function () { + $response = $this->get("AccessSecuredController/adminonly"); + $this->assertEquals( + 200, + $response->getStatusCode(), + "Permission codes are respected when set in \$allowed_actions" + ); + }); - Security::setCurrentUser(null); $response = $this->get('AccessBaseController/extensionmethod1'); $this->assertEquals( 200, @@ -253,14 +253,14 @@ class ControllerTest extends FunctionalTest "Access denied when index action is limited through allowed_actions, " . "and doesn't satisfy checks" ); - Security::setCurrentUser($adminUser); - $response = $this->get('IndexSecuredController/'); - $this->assertEquals( - 200, - $response->getStatusCode(), - "Access granted when index action is limited through allowed_actions, " . "and does satisfy checks" - ); - Security::setCurrentUser(null); + Member::actAs($adminUser, function () { + $response = $this->get('IndexSecuredController/'); + $this->assertEquals( + 200, + $response->getStatusCode(), + "Access granted when index action is limited through allowed_actions, " . "and does satisfy checks" + ); + }); } /**