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\CountablePromotionSubjectInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Saša Stamenković <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class CartQuantityRuleCheckerSpec extends ObjectBehavior |
24
|
|
|
{ |
25
|
|
|
function it_is_a_rule_checker(): void |
26
|
|
|
{ |
27
|
|
|
$this->shouldImplement(RuleCheckerInterface::class); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_recognizes_empty_subject_as_not_eligible(CountablePromotionSubjectInterface $subject): void |
31
|
|
|
{ |
32
|
|
|
$subject->getPromotionSubjectCount()->willReturn(0); |
33
|
|
|
|
34
|
|
|
$this->isEligible($subject, ['count' => 10])->shouldReturn(false); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_recognizes_a_subject_as_not_eligible_if_a_cart_quantity_is_less_then_configured( |
38
|
|
|
CountablePromotionSubjectInterface $subject |
39
|
|
|
): void { |
40
|
|
|
$subject->getPromotionSubjectCount()->willReturn(7); |
41
|
|
|
|
42
|
|
|
$this->isEligible($subject, ['count' => 10])->shouldReturn(false); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function it_recognizes_a_subject_as_eligible_if_a_cart_quantity_is_greater_then_configured( |
46
|
|
|
CountablePromotionSubjectInterface $subject |
47
|
|
|
): void { |
48
|
|
|
$subject->getPromotionSubjectCount()->willReturn(12); |
49
|
|
|
|
50
|
|
|
$this->isEligible($subject, ['count' => 10])->shouldReturn(true); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
function it_recognizes_a_subject_as_eligible_if_a_cart_quantity_is_equal_with_configured( |
54
|
|
|
CountablePromotionSubjectInterface $subject |
55
|
|
|
): void { |
56
|
|
|
$subject->getPromotionSubjectCount()->willReturn(10); |
57
|
|
|
|
58
|
|
|
$this->isEligible($subject, ['count' => 10])->shouldReturn(true); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|