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\ResourceBundle\Storage; |
13
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
15
|
|
|
use Sylius\Component\Resource\Storage\StorageInterface; |
16
|
|
|
use Symfony\Component\HttpFoundation\Session\Session; |
17
|
|
|
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Kamil Kokot <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
final class SessionStorageSpec extends ObjectBehavior |
23
|
|
|
{ |
24
|
|
|
function let() |
25
|
|
|
{ |
26
|
|
|
$this->beConstructedWith(new Session(new MockArraySessionStorage())); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
function it_is_a_storage() |
30
|
|
|
{ |
31
|
|
|
$this->shouldImplement(StorageInterface::class); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function it_does_not_have_a_named_value_if_it_was_not_set_previously() |
35
|
|
|
{ |
36
|
|
|
$this->get('name')->shouldReturn(null); |
37
|
|
|
$this->has('name')->shouldReturn(false); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function it_stores_a_named_value() |
41
|
|
|
{ |
42
|
|
|
$this->set('name', 'value'); |
43
|
|
|
|
44
|
|
|
$this->get('name')->shouldReturn('value'); |
45
|
|
|
$this->has('name')->shouldReturn(true); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_removes_a_stored_named_value() |
49
|
|
|
{ |
50
|
|
|
$this->set('name', 'value'); |
51
|
|
|
$this->remove('name'); |
52
|
|
|
|
53
|
|
|
$this->get('name')->shouldReturn(null); |
54
|
|
|
$this->has('name')->shouldReturn(false); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function it_returns_default_value_if_none_found() |
58
|
|
|
{ |
59
|
|
|
$this->get('name', 'default')->shouldReturn('default'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
function it_returns_all_values() |
63
|
|
|
{ |
64
|
|
|
$this->set('foo', 'bar'); |
65
|
|
|
$this->set('buzz', 'lightyear'); |
66
|
|
|
|
67
|
|
|
$this->all()->shouldReturn([ |
68
|
|
|
'foo' => 'bar', |
69
|
|
|
'buzz' => 'lightyear', |
70
|
|
|
]); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|