Completed
Push — master ( 10cfb1...be140a )
by Joachim
02:56
created

PaymentTest::testCreateFromDandomainPayment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Tests\Entity;
4
5
use Loevgaard\DandomainAltapayBundle\Entity\Payment;
6
use PHPUnit\Framework\TestCase;
7
8
class PaymentTest extends TestCase
9
{
10
    public function testGettersSetters()
11
    {
12
        $payment = new Payment();
13
14
        $created = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2017-10-01 04:00:00');
15
        $updated = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2017-10-01 04:00:01');
16
17
        $payment
18
            ->setId(1)
19
            ->setAltapayId('altapayid')
20
            ->setCardStatus('cardstatus')
21
            ->setCreditCardToken('cctoken')
22
            ->setCreditCardMaskedPan('ccmaskedpan')
23
            ->setThreeDSecureResult('3dres')
24
            ->setLiableForChargeback('liable')
25
            ->setBlacklistToken('blacklisttoken')
26
            ->setShop('shop')
27
            ->setTerminal('terminal')
28
            ->setTransactionStatus('transactionstatus')
29
            ->setReasonCode('reasoncode')
30
            ->setMerchantCurrency(208)
31
            ->setMerchantCurrencyAlpha('DKK')
32
            ->setCardHolderCurrency(700)
33
            ->setCardHolderCurrencyAlpha('EUR')
34
            ->setReservedAmount(250.5)
35
            ->setCapturedAmount(125.5)
36
            ->setRefundedAmount(300.4)
37
            ->setRecurringDefaultAmount(400.9)
38
            ->setCreatedDate($created)
39
            ->setUpdatedDate($updated)
40
            ->setPaymentNature('paymentnature')
41
            ->setSupportsRefunds(false)
42
            ->setSupportsRelease(false)
43
            ->setSupportsMultipleCaptures(true)
44
            ->setSupportsMultipleRefunds(true)
45
            ->setFraudRiskScore(13.37)
46
            ->setFraudExplanation('fraudexplanation')
47
        ;
48
49
        $this->assertSame(1, $payment->getId());
50
        $this->assertSame('altapayid', $payment->getAltapayId());
51
        $this->assertSame('cardstatus', $payment->getCardStatus());
52
        $this->assertSame('cctoken', $payment->getCreditCardToken());
53
        $this->assertSame('ccmaskedpan', $payment->getCreditCardMaskedPan());
54
        $this->assertSame('3dres', $payment->getThreeDSecureResult());
55
        $this->assertSame('liable', $payment->getLiableForChargeback());
56
        $this->assertSame('blacklisttoken', $payment->getBlacklistToken());
57
        $this->assertSame('shop', $payment->getShop());
58
        $this->assertSame('terminal', $payment->getTerminal());
59
        $this->assertSame('transactionstatus', $payment->getTransactionStatus());
60
        $this->assertSame('reasoncode', $payment->getReasonCode());
61
        $this->assertSame(208, $payment->getMerchantCurrency());
62
        $this->assertSame('DKK', $payment->getMerchantCurrencyAlpha());
63
        $this->assertSame(700, $payment->getCardHolderCurrency());
64
        $this->assertSame('EUR', $payment->getCardHolderCurrencyAlpha());
65
        $this->assertSame(250.5, $payment->getReservedAmount());
66
        $this->assertSame(125.5, $payment->getCapturedAmount());
67
        $this->assertSame(300.4, $payment->getRefundedAmount());
68
        $this->assertSame(400.9, $payment->getRecurringDefaultAmount());
69
        $this->assertSame($created, $payment->getCreatedDate());
70
        $this->assertSame($updated, $payment->getUpdatedDate());
71
        $this->assertSame('paymentnature', $payment->getPaymentNature());
72
        $this->assertSame(false, $payment->getSupportsRefunds());
73
        $this->assertSame(false, $payment->getSupportsRelease());
74
        $this->assertSame(true, $payment->getSupportsMultipleCaptures());
75
        $this->assertSame(true, $payment->getSupportsMultipleRefunds());
76
        $this->assertSame(13.37, $payment->getFraudRiskScore());
77
        $this->assertSame('fraudexplanation', $payment->getFraudExplanation());
78
    }
79
80 View Code Duplication
    public function testIsCaptureable1()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
    {
82
        $payment = new Payment();
83
84
        $payment
85
            ->setReservedAmount(100)
86
            ->setCapturedAmount(100)
87
            ->setRefundedAmount(0)
88
        ;
89
90
        $this->assertSame(false, $payment->isCaptureable());
91
    }
92
93 View Code Duplication
    public function testIsCaptureable2()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
    {
95
        $payment = new Payment();
96
97
        $payment
98
            ->setReservedAmount(100)
99
            ->setCapturedAmount(10)
100
            ->setRefundedAmount(0)
101
            ->setSupportsMultipleCaptures(false)
102
        ;
103
104
        $this->assertSame(false, $payment->isCaptureable());
105
    }
106
107 View Code Duplication
    public function testIsCaptureable3()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
108
    {
109
        $payment = new Payment();
110
111
        $payment
112
            ->setReservedAmount(100)
113
            ->setCapturedAmount(0)
114
            ->setRefundedAmount(0)
115
        ;
116
117
        $this->assertSame(true, $payment->isCaptureable());
118
    }
119
120
    public function testIsRefundable1()
121
    {
122
        $payment = new Payment();
123
124
        $payment
125
            ->setCapturedAmount(100)
126
            ->setRefundedAmount(100)
127
        ;
128
129
        $this->assertSame(false, $payment->isRefundable());
130
    }
131
132
    public function testIsRefundable2()
133
    {
134
        $payment = new Payment();
135
136
        $payment
137
            ->setCapturedAmount(100)
138
            ->setRefundedAmount(50)
139
            ->setSupportsMultipleRefunds(false)
140
        ;
141
142
        $this->assertSame(false, $payment->isRefundable());
143
    }
144
145
    public function testIsRefundable3()
146
    {
147
        $payment = new Payment();
148
149
        $payment
150
            ->setCapturedAmount(100)
151
            ->setRefundedAmount(0)
152
        ;
153
154
        $this->assertSame(true, $payment->isRefundable());
155
    }
156
}
157