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\Model; |
15
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Component\Promotion\Model\PromotionCouponInterface; |
18
|
|
|
use Sylius\Component\Promotion\Model\PromotionInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Saša Stamenković <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class PromotionCouponSpec extends ObjectBehavior |
24
|
|
|
{ |
25
|
|
|
function it_is_a_promotion_coupon(): void |
26
|
|
|
{ |
27
|
|
|
$this->shouldImplement(PromotionCouponInterface::class); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_does_not_have_id_by_default(): void |
31
|
|
|
{ |
32
|
|
|
$this->getId()->shouldReturn(null); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function its_code_is_mutable(): void |
36
|
|
|
{ |
37
|
|
|
$this->setCode('xxx'); |
38
|
|
|
$this->getCode()->shouldReturn('xxx'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function it_does_not_have_code_by_default(): void |
42
|
|
|
{ |
43
|
|
|
$this->getCode()->shouldReturn(null); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
function it_has_no_usage_limit_by_default(): void |
47
|
|
|
{ |
48
|
|
|
$this->getUsageLimit()->shouldReturn(null); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function its_usage_limit_is_mutable(): void |
52
|
|
|
{ |
53
|
|
|
$this->setUsageLimit(10); |
54
|
|
|
$this->getUsageLimit()->shouldReturn(10); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function it_does_not_have_used_by_default(): void |
58
|
|
|
{ |
59
|
|
|
$this->getUsed()->shouldReturn(0); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
function its_used_is_mutable(): void |
63
|
|
|
{ |
64
|
|
|
$this->setUsed(5); |
65
|
|
|
$this->getUsed()->shouldReturn(5); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
function its_used_is_incrementable(): void |
69
|
|
|
{ |
70
|
|
|
$this->incrementUsed(); |
71
|
|
|
$this->getUsed()->shouldReturn(1); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
function its_used_is_decrementable(): void |
75
|
|
|
{ |
76
|
|
|
$this->setUsed(5); |
77
|
|
|
$this->decrementUsed(); |
78
|
|
|
$this->getUsed()->shouldReturn(4); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
function it_does_not_have_promotion_by_default(): void |
82
|
|
|
{ |
83
|
|
|
$this->getPromotion()->shouldReturn(null); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
function its_promotion_by_is_mutable(PromotionInterface $promotion): void |
87
|
|
|
{ |
88
|
|
|
$this->setPromotion($promotion); |
89
|
|
|
$this->getPromotion()->shouldReturn($promotion); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|