Skip to content

Commit f2c713e

Browse files
committed
testAuthenticateSuccessWithDirectCollection
1 parent d4d218a commit f2c713e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/TestCase/Authenticator/SessionAuthenticatorTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,34 @@ public function testAuthenticateSuccessWithoutCollectionButObject()
148148
$this->assertSame(Result::SUCCESS, $result->getStatus());
149149
}
150150

151+
/**
152+
* Test authentication
153+
*
154+
* @return void
155+
*/
156+
public function testAuthenticateSuccessWithDirectCollection()
157+
{
158+
$request = ServerRequestFactory::fromGlobals(['REQUEST_URI' => '/']);
159+
160+
$this->sessionMock->expects($this->once())
161+
->method('read')
162+
->with('Auth')
163+
->willReturn([
164+
'username' => 'mariano',
165+
'password' => 'password',
166+
]);
167+
168+
$request = $request->withAttribute('session', $this->sessionMock);
169+
170+
$authenticator = new SessionAuthenticator(new IdentifierCollection(), [
171+
'identifier' => new IdentifierCollection(['Authentication.Password']),
172+
]);
173+
$result = $authenticator->authenticate($request);
174+
175+
$this->assertInstanceOf(Result::class, $result);
176+
$this->assertSame(Result::SUCCESS, $result->getStatus());
177+
}
178+
151179
/**
152180
* Test authentication
153181
*

0 commit comments

Comments
 (0)