Completed
Push — master ( 71b70e...42cf72 )
by Kamil
19:08
created

SharedStorageSpec::it_overrides_clipboard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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\Component\Core\Test\Services;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Core\Model\ChannelInterface;
16
use Sylius\Component\Core\Model\ProductInterface;
17
use Sylius\Component\Core\Test\Services\SharedStorage;
18
use Sylius\Component\Core\Test\Services\SharedStorageInterface;
19
20
/**
21
 * @mixin SharedStorage
22
 *
23
 * @author Arkadiusz Krakowiak <[email protected]>
24
 */
25
class SharedStorageSpec extends ObjectBehavior
26
{
27
    function it_is_initializable()
28
    {
29
        $this->shouldHaveType('Sylius\Component\Core\Test\Services\SharedStorage');
30
    }
31
32
    function it_implements_shared_storage_interface()
33
    {
34
        $this->shouldImplement(SharedStorageInterface::class);
35
    }
36
37
    function it_has_resources_in_clipboard(ChannelInterface $channel, ProductInterface $product)
38
    {
39
        $this->setCurrentResource('channel1', $channel);
40
        $this->getCurrentResource('channel1')->shouldReturn($channel);
41
42
        $this->setCurrentResource('product1', $product);
43
        $this->getCurrentResource('product1')->shouldReturn($product);
44
    }
45
46
    function it_returns_latest_added_resource(ChannelInterface $channel, ProductInterface $product)
47
    {
48
        $this->setCurrentResource('channel1', $channel);
49
        $this->setCurrentResource('product1', $product);
50
51
        $this->getLatestResource()->shouldReturn($product);
52
    }
53
54
    function it_overrides_existing_resource_key(ChannelInterface $firstChannel, ChannelInterface $secondChannel)
55
    {
56
        $this->setCurrentResource('channel', $firstChannel);
57
        $this->setCurrentResource('channel', $secondChannel);
58
59
        $this->getCurrentResource('channel')->shouldReturn($secondChannel);
60
    }
61
62
    function its_clipboard_can_be_set(ChannelInterface $channel)
63
    {
64
        $this->setClipboard(['channel' => $channel]);
65
66
        $this->getCurrentResource('channel')->shouldReturn($channel);
67
    }
68
}
69