|
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
|
|
|
|