Completed
Push — symfony3 ( 06e2ee...17e915 )
by Kamil
46:11 queued 26:57
created

LimitingOrderItemQuantityModifierSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 28
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_order_item_modifier_interface() 0 4 1
A it_restricts_max_item_quantity_to_the_stated_limit() 0 10 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\Cart\Modifier;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Core\Cart\Modifier\LimitingOrderItemQuantityModifier;
16
use Sylius\Component\Order\Model\OrderItemInterface;
17
use Sylius\Component\Order\Modifier\OrderItemQuantityModifierInterface;
18
19
/**
20
 * @author Jan Góralski <[email protected]>
21
 */
22
final class LimitingOrderItemQuantityModifierSpec extends ObjectBehavior
23
{
24
    function let(OrderItemQuantityModifierInterface $itemQuantityModifier)
25
    {
26
        $this->beConstructedWith($itemQuantityModifier, 1000);
27
    }
28
29
    function it_is_initializable()
30
    {
31
        $this->shouldHaveType(LimitingOrderItemQuantityModifier::class);
32
    }
33
34
    function it_implements_order_item_modifier_interface()
35
    {
36
        $this->shouldImplement(OrderItemQuantityModifierInterface::class);
37
    }
38
39
    function it_restricts_max_item_quantity_to_the_stated_limit(
40
        OrderItemQuantityModifierInterface $itemQuantityModifier,
41
        OrderItemInterface $orderItem
42
    ) {
43
        $orderItem->getQuantity()->willReturn(0);
44
45
        $itemQuantityModifier->modify($orderItem, 1000)->shouldBeCalled();
46
47
        $this->modify($orderItem, 9999);
48
    }
49
}
50