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

it_is_initializable()   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\Eligibility;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Promotion\Checker\Eligibility\PromotionCouponEligibilityCheckerInterface;
18
use Sylius\Component\Promotion\Model\PromotionCouponInterface;
19
use Sylius\Component\Promotion\Model\PromotionSubjectInterface;
20
21
/**
22
 * @author Kamil Kokot <[email protected]>
23
 */
24
final class PromotionCouponDurationEligibilityCheckerSpec extends ObjectBehavior
25
{
26
    function it_is_a_promotion_coupon_eligibility_checker(): void
27
    {
28
        $this->shouldImplement(PromotionCouponEligibilityCheckerInterface::class);
29
    }
30
31
    function it_returns_true_if_promotion_coupon_does_not_expire(
32
        PromotionSubjectInterface $promotionSubject,
33
        PromotionCouponInterface $promotionCoupon
34
    ): void {
35
        $promotionCoupon->getExpiresAt()->willReturn(null);
36
37
        $this->isEligible($promotionSubject, $promotionCoupon)->shouldReturn(true);
38
    }
39
40
    function it_returns_true_if_promotion_coupon_has_not_expired_yet(
41
        PromotionSubjectInterface $promotionSubject,
42
        PromotionCouponInterface $promotionCoupon
43
    ): void {
44
        $promotionCoupon->getExpiresAt()->willReturn(new \DateTime('tomorrow'));
45
46
        $this->isEligible($promotionSubject, $promotionCoupon)->shouldReturn(true);
47
    }
48
49
    function it_returns_false_if_promotion_coupon_has_already_expired(
50
        PromotionSubjectInterface $promotionSubject,
51
        PromotionCouponInterface $promotionCoupon
52
    ): void {
53
        $promotionCoupon->getExpiresAt()->willReturn(new \DateTime('yesterday'));
54
55
        $this->isEligible($promotionSubject, $promotionCoupon)->shouldReturn(false);
56
    }
57
}
58