diff --git a/tests/TestCase/Authenticator/SessionAuthenticatorTest.php b/tests/TestCase/Authenticator/SessionAuthenticatorTest.php index 2862a182..41ba8a2a 100644 --- a/tests/TestCase/Authenticator/SessionAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/SessionAuthenticatorTest.php @@ -24,6 +24,7 @@ use Cake\Http\Exception\UnauthorizedException; use Cake\Http\Response; use Cake\Http\ServerRequestFactory; +use Cake\Http\Session; use Cake\ORM\TableRegistry; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -58,11 +59,7 @@ public function setUp(): void 'Authentication.Password', ]); - $class = 'Cake\Http\Session'; - if (!class_exists($class)) { - $class = '\Cake\Network\Session'; - } - $this->sessionMock = $this->getMockBuilder($class) + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->onlyMethods(['read', 'write', 'delete', 'renew', 'check']) ->getMock(); diff --git a/tests/TestCase/Controller/Component/AuthenticationComponentTest.php b/tests/TestCase/Controller/Component/AuthenticationComponentTest.php index 51cf7573..ec73d44c 100644 --- a/tests/TestCase/Controller/Component/AuthenticationComponentTest.php +++ b/tests/TestCase/Controller/Component/AuthenticationComponentTest.php @@ -55,11 +55,6 @@ class AuthenticationComponentTest extends TestCase */ protected $request; - /** - * @var \Cake\Http\Response - */ - protected $response; - /** * @var \Authentication\AuthenticationService */ @@ -574,7 +569,7 @@ public function testImpersonate() $request = $this->request ->withAttribute('identity', $identity) ->withAttribute('authentication', $this->service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); @@ -605,7 +600,7 @@ public function testImpersonateDecoratorIgnored() $request = $this->request ->withAttribute('identity', $identity) ->withAttribute('authentication', $this->service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); @@ -630,7 +625,7 @@ public function testImpersonateNoIdentity() $impersonated = new ArrayObject(['username' => 'larry']); $request = $this->request ->withAttribute('authentication', $this->service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); $this->expectException(UnauthenticatedException::class); @@ -659,7 +654,7 @@ public function testImpersonateFailure() $request = $this->request ->withAttribute('identity', $identity) ->withAttribute('authentication', $service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); $this->expectException(UnexpectedValueException::class); @@ -680,7 +675,7 @@ public function testStopImpersonating() $this->request->getSession()->write('AuthImpersonate', $impersonator); $this->service->authenticate($this->request); $request = $this->request->withAttribute('authentication', $this->service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); $this->assertEquals($impersonator, $controller->getRequest()->getSession()->read('AuthImpersonate')); @@ -710,7 +705,7 @@ public function testStopImpersonatingFailure() $request = $this->request ->withAttribute('identity', $identity) ->withAttribute('authentication', $service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); $this->expectException(UnexpectedValueException::class); @@ -733,7 +728,7 @@ public function testIsImpersonating() $request = $this->request ->withAttribute('authentication', $this->service) ->withAttribute('identity', new Identity($impersonated)); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); @@ -757,7 +752,7 @@ public function testGetImpersonationAuthenticationServiceFailure() $request = $this->request ->withAttribute('authentication', $service) ->withAttribute('identity', new Identity($user)); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry); @@ -778,7 +773,7 @@ public function testIsImpersonatingNotImpersonating() $this->request->getSession()->write('Auth', $user); $this->service->authenticate($this->request); $request = $this->request->withAttribute('authentication', $this->service); - $controller = new Controller($request, $this->response); + $controller = new Controller($request); $registry = new ComponentRegistry($controller); $component = new AuthenticationComponent($registry);