|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace spec\Sylius\Bundle\UserBundle\Authentication; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use Sylius\Bundle\UserBundle\Authentication\AuthenticationSuccessHandler; |
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
17
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
|
18
|
|
|
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; |
|
19
|
|
|
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler; |
|
20
|
|
|
use Symfony\Component\Security\Http\HttpUtils; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @mixin AuthenticationSuccessHandler |
|
24
|
|
|
* |
|
25
|
|
|
* @author Arkadiusz Krakowiak <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class AuthenticationSuccessHandlerSpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function let(HttpUtils $httpUtils) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->beConstructedWith($httpUtils); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_is_initializable() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->shouldHaveType('Sylius\Bundle\UserBundle\Authentication\AuthenticationSuccessHandler'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function it_extends_default_authentication_success_handler() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->shouldHaveType(DefaultAuthenticationSuccessHandler::class); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
function it_is_a_authentication_success_handler() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->shouldImplement(AuthenticationSuccessHandlerInterface::class); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function it_returns_json_response_if_it_was_ajax_call( |
|
50
|
|
|
Request $request, |
|
51
|
|
|
TokenInterface $token |
|
52
|
|
|
) { |
|
53
|
|
|
$request->isXmlHttpRequest()->willReturn(true); |
|
54
|
|
|
|
|
55
|
|
|
$this->onAuthenticationSuccess($request, $token); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|