Completed
Push — scalar-types/resource ( 4814fd )
by Kamil
23:02
created

its_amount_should_accept_only_integer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 8
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A PaymentSpec::it_initializes_creation_date_by_default() 0 4 1
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\Payment\Model;
15
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Component\Payment\Model\PaymentInterface;
18
use Sylius\Component\Payment\Model\PaymentMethodInterface;
19
20
/**
21
 * @author Paweł Jędrzejewski <[email protected]>
22
 */
23
final class PaymentSpec extends ObjectBehavior
24
{
25
    function it_implements_sylius_payment_interface(): void
26
    {
27
        $this->shouldImplement(PaymentInterface::class);
28
    }
29
30
    function it_has_no_id_by_default(): void
31
    {
32
        $this->getId()->shouldReturn(null);
33
    }
34
35
    function it_has_no_payment_method_by_default(): void
36
    {
37
        $this->getMethod()->shouldReturn(null);
38
    }
39
40
    function its_payment_method_is_mutable(PaymentMethodInterface $method): void
41
    {
42
        $this->setMethod($method);
43
        $this->getMethod()->shouldReturn($method);
44
    }
45
46
    function it_has_no_currency_code_by_default(): void
47
    {
48
        $this->getCurrencyCode()->shouldReturn(null);
49
    }
50
51
    function its_currency_code_is_mutable(): void
52
    {
53
        $this->setCurrencyCode('EUR');
54
        $this->getCurrencyCode()->shouldReturn('EUR');
55
    }
56
57
    function it_has_amount_equal_to_0_by_default(): void
58
    {
59
        $this->getAmount()->shouldReturn(0);
60
    }
61
62
    function its_amount_is_mutable(): void
63
    {
64
        $this->setAmount(4999);
65
        $this->getAmount()->shouldReturn(4999);
66
    }
67
68
    function it_has_cart_state_by_default(): void
69
    {
70
        $this->getState()->shouldReturn(PaymentInterface::STATE_CART);
71
    }
72
73
    function its_state_is_mutable(): void
74
    {
75
        $this->setState(PaymentInterface::STATE_COMPLETED);
76
        $this->getState()->shouldReturn(PaymentInterface::STATE_COMPLETED);
77
    }
78
79
    function it_initializes_creation_date_by_default(): void
80
    {
81
        $this->getCreatedAt()->shouldHaveType('DateTime');
82
    }
83
84
    function its_creation_date_is_mutable(): void
85
    {
86
        $date = new \DateTime('last year');
87
88
        $this->setCreatedAt($date);
89
        $this->getCreatedAt()->shouldReturn($date);
90
    }
91
92
    function it_has_no_last_update_date_by_default(): void
93
    {
94
        $this->getUpdatedAt()->shouldReturn(null);
95
    }
96
97
    function its_last_update_date_is_mutable(): void
98
    {
99
        $date = new \DateTime('last year');
100
101
        $this->setUpdatedAt($date);
102
        $this->getUpdatedAt()->shouldReturn($date);
103
    }
104
105
    function its_details_are_mutable(): void
106
    {
107
        $this->setDetails(['foo', 'bar']);
108
        $this->getDetails()->shouldReturn(['foo', 'bar']);
109
    }
110
}
111