Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions tests/TestCase/Authenticator/SessionAuthenticatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class AuthenticationComponentTest extends TestCase
*/
protected $request;

/**
* @var \Cake\Http\Response
*/
protected $response;

/**
* @var \Authentication\AuthenticationService
*/
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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'));
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down