Completed
Push — scalar-types/taxonomy ( 4d330b )
by Kamil
23:21
created

it_is_be_a_rule_checker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
declare(strict_types=1);
13
14
namespace spec\Sylius\Component\Promotion\Checker\Rule;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Promotion\Checker\Rule\RuleCheckerInterface;
18
use Sylius\Component\Promotion\Model\PromotionSubjectInterface;
19
20
/**
21
 * @author Saša Stamenković <[email protected]>
22
 */
23
final class ItemTotalRuleCheckerSpec extends ObjectBehavior
24
{
25
    function it_is_be_a_rule_checker(): void
26
    {
27
        $this->shouldImplement(RuleCheckerInterface::class);
28
    }
29
30
    function it_recognizes_an_empty_subject_as_not_eligible(PromotionSubjectInterface $subject): void
31
    {
32
        $subject->getPromotionSubjectTotal()->willReturn(0);
33
34
        $this->isEligible($subject, ['amount' => 500])->shouldReturn(false);
35
    }
36
37
    function it_recognizes_a_subject_as_not_eligible_if_a_subject_total_is_less_then_configured(
38
        PromotionSubjectInterface $subject
39
    ): void {
40
        $subject->getPromotionSubjectTotal()->willReturn(400);
41
42
        $this->isEligible($subject, ['amount' => 500])->shouldReturn(false);
43
    }
44
45
    function it_recognizes_a_subject_as_eligible_if_a_subject_total_is_greater_then_configured(
46
        PromotionSubjectInterface $subject
47
    ): void {
48
        $subject->getPromotionSubjectTotal()->willReturn(600);
49
50
        $this->isEligible($subject, ['amount' => 500])->shouldReturn(true);
51
    }
52
53
    function it_recognizes_a_subject_as_eligible_if_a_subject_total_is_equal_with_configured(
54
        PromotionSubjectInterface $subject
55
    ): void {
56
        $subject->getPromotionSubjectTotal()->willReturn(500);
57
58
        $this->isEligible($subject, ['amount' => 500])->shouldReturn(true);
59
    }
60
}
61