Completed
Push — master ( 994ba8...dbff07 )
by Kamil
19:19
created

UnitCountRuleCheckerSpec   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 49
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_is_Sylius_rule_checker() 0 4 1
A it_should_recognize_empty_subject_as_not_eligible() 0 6 1
A it_should_recognize_subject_as_not_eligible_if_unit_count_is_less_then_configured() 0 7 1
A it_should_recognize_subject_as_eligible_if_unit_count_is_greater_then_configured() 0 7 1
A it_should_recognize_subject_as_eligible_if_unit_count_is_equal_with_configured_depending_on_equal_setting() 0 8 1
A it_returns_unit_count_configuration_form_type() 0 4 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\Shipping\Checker;
13
14
use PhpSpec\ObjectBehavior;
15
use Sylius\Component\Shipping\Checker\RuleCheckerInterface;
16
use Sylius\Component\Shipping\Model\ShippingSubjectInterface;
17
18
/**
19
 * @author Saša Stamenković <[email protected]>
20
 */
21
class UnitCountRuleCheckerSpec extends ObjectBehavior
22
{
23
    function it_is_initializable()
24
    {
25
        $this->shouldHaveType('Sylius\Component\Shipping\Checker\UnitCountRuleChecker');
26
    }
27
28
    function it_is_Sylius_rule_checker()
29
    {
30
        $this->shouldImplement(RuleCheckerInterface::class);
31
    }
32
33
    function it_should_recognize_empty_subject_as_not_eligible(ShippingSubjectInterface $subject)
34
    {
35
        $subject->getShippingUnitCount()->shouldBeCalled()->willReturn(0);
36
37
        $this->isEligible($subject, ['count' => 10, 'equal' => false])->shouldReturn(false);
38
    }
39
40
    function it_should_recognize_subject_as_not_eligible_if_unit_count_is_less_then_configured(
41
        ShippingSubjectInterface $subject
42
    ) {
43
        $subject->getShippingUnitCount()->shouldBeCalled()->willReturn(7);
44
45
        $this->isEligible($subject, ['count' => 10, 'equal' => false])->shouldReturn(false);
46
    }
47
48
    function it_should_recognize_subject_as_eligible_if_unit_count_is_greater_then_configured(
49
        ShippingSubjectInterface $subject
50
    ) {
51
        $subject->getShippingUnitCount()->shouldBeCalled()->willReturn(12);
52
53
        $this->isEligible($subject, ['count' => 10, 'equal' => false])->shouldReturn(true);
54
    }
55
56
    function it_should_recognize_subject_as_eligible_if_unit_count_is_equal_with_configured_depending_on_equal_setting(
57
        ShippingSubjectInterface $subject
58
    ) {
59
        $subject->getShippingUnitCount()->shouldBeCalled()->willReturn(10);
60
61
        $this->isEligible($subject, ['count' => 10, 'equal' => false])->shouldReturn(false);
62
        $this->isEligible($subject, ['count' => 10, 'equal' => true])->shouldReturn(true);
63
    }
64
65
    function it_returns_unit_count_configuration_form_type()
66
    {
67
        $this->getConfigurationFormType()->shouldReturn('sylius_shipping_rule_unit_count_configuration');
68
    }
69
}
70