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\ChannelBundle\Context\FakeChannel; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Bundle\ChannelBundle\Context\FakeChannel\FakeChannelCodeProvider; |
16
|
|
|
use Sylius\Bundle\ChannelBundle\Context\FakeChannel\FakeChannelCodeProviderInterface; |
17
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
18
|
|
|
use Symfony\Component\HttpFoundation\Request; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @mixin FakeChannelCodeProvider |
22
|
|
|
* |
23
|
|
|
* @author Kamil Kokot <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class FakeChannelCodeProviderSpec extends ObjectBehavior |
26
|
|
|
{ |
27
|
|
|
function it_is_initializable() |
28
|
|
|
{ |
29
|
|
|
$this->shouldHaveType('Sylius\Bundle\ChannelBundle\Context\FakeChannel\FakeChannelCodeProvider'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_implements_channel_code_provider_interface() |
33
|
|
|
{ |
34
|
|
|
$this->shouldImplement(FakeChannelCodeProviderInterface::class); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_returns_fake_channel_code_from_query_string(Request $request, ParameterBag $queryBag) |
38
|
|
|
{ |
39
|
|
|
$queryBag->get('_channel_code')->willReturn('channel_code_form_get'); |
40
|
|
|
$request->query = $queryBag; |
41
|
|
|
|
42
|
|
|
$this->getCode($request)->shouldReturn('channel_code_form_get'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function it_returns_fake_channel_code_from_cookie_if_there_is_none_in_query_string( |
46
|
|
|
Request $request, |
47
|
|
|
ParameterBag $queryBag, |
48
|
|
|
ParameterBag $cookiesBag |
49
|
|
|
) { |
50
|
|
|
$queryBag->get('_channel_code')->willReturn(null); |
51
|
|
|
$request->query = $queryBag; |
52
|
|
|
|
53
|
|
|
$cookiesBag->get('_channel_code')->willReturn('channel_code_form_cookie'); |
54
|
|
|
$request->cookies = $cookiesBag; |
55
|
|
|
|
56
|
|
|
$this->getCode($request)->shouldReturn('channel_code_form_cookie'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
function it_returns_null_channel_code_if_no_fake_channel_code_was_found( |
60
|
|
|
Request $request, |
61
|
|
|
ParameterBag $queryBag, |
62
|
|
|
ParameterBag $cookiesBag |
63
|
|
|
) { |
64
|
|
|
$queryBag->get('_channel_code')->willReturn(null); |
65
|
|
|
$request->query = $queryBag; |
66
|
|
|
|
67
|
|
|
$cookiesBag->get('_channel_code')->willReturn(null); |
68
|
|
|
$request->cookies = $cookiesBag; |
69
|
|
|
|
70
|
|
|
$this->getCode($request)->shouldReturn(null); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|