[Security] Added tests for the DefaultLogoutSuccessHandler.
This commit is contained in:
parent
30fe940d11
commit
8d5f39f9e5
@ -39,11 +39,15 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas
|
|||||||
$this->markTestSkipped('The "HttpFoundation" component is not available');
|
$this->markTestSkipped('The "HttpFoundation" component is not available');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!class_exists('Psr\Log\LoggerInterface')) {
|
||||||
|
$this->markTestSkipped('The "LoggerInterface" is not available');
|
||||||
|
}
|
||||||
|
|
||||||
$this->httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$this->httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||||
$this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
|
$this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
|
||||||
$this->logger = $this->getMock('Psr\Log\LoggerInterface');
|
$this->logger = $this->getMock('Psr\Log\LoggerInterface');
|
||||||
|
|
||||||
$this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session');
|
$this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
|
||||||
$this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
|
$this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
|
||||||
$this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
|
$this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
|
||||||
$this->exception = $this->getMock('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
$this->exception = $this->getMock('Symfony\Component\Security\Core\Exception\AuthenticationException');
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\Security\Tests\Http\Logout;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Security\Http\Logout\DefaultLogoutSuccessHandler;
|
||||||
|
|
||||||
|
class DefaultLogoutSuccessHandlerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
if (!class_exists('Symfony\Component\HttpFoundation\Request')) {
|
||||||
|
$this->markTestSkipped('The "HttpFoundation" component is not available');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLogout()
|
||||||
|
{
|
||||||
|
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
|
||||||
|
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
|
||||||
|
|
||||||
|
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
|
||||||
|
$httpUtils->expects($this->once())
|
||||||
|
->method('createRedirectResponse')
|
||||||
|
->with($request, '/dashboard')
|
||||||
|
->will($this->returnValue($response));
|
||||||
|
|
||||||
|
$handler = new DefaultLogoutSuccessHandler($httpUtils, '/dashboard');
|
||||||
|
$result = $handler->onLogoutSuccess($request);
|
||||||
|
|
||||||
|
$this->assertSame($response, $result);
|
||||||
|
}
|
||||||
|
}
|
@ -66,7 +66,7 @@ class SessionAuthenticationStrategyTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
|
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
|
||||||
|
|
||||||
if (!is_null($session)) {
|
if (null !== $session) {
|
||||||
$request->expects($this->any())->method('getSession')->will($this->returnValue($session));
|
$request->expects($this->any())->method('getSession')->will($this->returnValue($session));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user