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