This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Loevgaard\DandomainAltapayBundle\Tests\Entity; |
||
4 | |||
5 | use Loevgaard\DandomainAltapayBundle\Entity\Payment; |
||
6 | use Loevgaard\DandomainAltapayBundle\Entity\PaymentLine; |
||
7 | use Money\Currency; |
||
8 | use Money\Money; |
||
9 | use PHPUnit\Framework\TestCase; |
||
10 | |||
11 | class PaymentTest extends TestCase |
||
12 | { |
||
13 | public function testGettersSetters() |
||
14 | { |
||
15 | $payment = new Payment(); |
||
16 | |||
17 | $created = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2017-10-01 04:00:00'); |
||
18 | $updated = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2017-10-01 04:00:01'); |
||
19 | |||
20 | $reservedAmount = new Money(25050, new Currency('DKK')); |
||
21 | $capturedAmount = new Money(30020, new Currency('DKK')); |
||
22 | $refundedAmount = new Money(40040, new Currency('DKK')); |
||
23 | $recurringDefaultAmount = new Money(50060, new Currency('DKK')); |
||
24 | $totalAmount = new Money(60060, new Currency('DKK')); |
||
25 | $shippingFee = new Money(70080, new Currency('DKK')); |
||
26 | $paymentFee = new Money(80080, new Currency('DKK')); |
||
27 | |||
28 | $payment |
||
29 | ->setId(1) |
||
30 | ->setAltapayId('altapayid') |
||
31 | ->setCardStatus('cardstatus') |
||
32 | ->setCreditCardToken('cctoken') |
||
33 | ->setCreditCardMaskedPan('ccmaskedpan') |
||
34 | ->setThreeDSecureResult('3dres') |
||
35 | ->setLiableForChargeback('liable') |
||
36 | ->setBlacklistToken('blacklisttoken') |
||
37 | ->setShop('shop') |
||
38 | ->setTerminal('terminal') |
||
39 | ->setTransactionStatus('transactionstatus') |
||
40 | ->setReasonCode('reasoncode') |
||
41 | ->setMerchantCurrency(208) |
||
42 | ->setMerchantCurrencyAlpha('DKK') |
||
43 | ->setCardHolderCurrency(700) |
||
44 | ->setCardHolderCurrencyAlpha('EUR') |
||
45 | ->setReservedAmount($reservedAmount) |
||
46 | ->setCapturedAmount($capturedAmount) |
||
47 | ->setRefundedAmount($refundedAmount) |
||
48 | ->setRecurringDefaultAmount($recurringDefaultAmount) |
||
49 | ->setCreatedDate($created) |
||
50 | ->setUpdatedDate($updated) |
||
51 | ->setPaymentNature('paymentnature') |
||
52 | ->setSupportsRefunds(false) |
||
53 | ->setSupportsRelease(false) |
||
54 | ->setSupportsMultipleCaptures(true) |
||
55 | ->setSupportsMultipleRefunds(true) |
||
56 | ->setFraudRiskScore(13.37) |
||
57 | ->setFraudExplanation('fraudexplanation') |
||
58 | ->setTotalAmount($totalAmount) |
||
59 | ->setShippingFee($shippingFee) |
||
60 | ->setPaymentFee($paymentFee) |
||
61 | ; |
||
62 | |||
63 | $this->assertSame(1, $payment->getId()); |
||
64 | $this->assertSame('altapayid', $payment->getAltapayId()); |
||
65 | $this->assertSame('cardstatus', $payment->getCardStatus()); |
||
66 | $this->assertSame('cctoken', $payment->getCreditCardToken()); |
||
67 | $this->assertSame('ccmaskedpan', $payment->getCreditCardMaskedPan()); |
||
68 | $this->assertSame('3dres', $payment->getThreeDSecureResult()); |
||
69 | $this->assertSame('liable', $payment->getLiableForChargeback()); |
||
70 | $this->assertSame('blacklisttoken', $payment->getBlacklistToken()); |
||
71 | $this->assertSame('shop', $payment->getShop()); |
||
72 | $this->assertSame('terminal', $payment->getTerminal()); |
||
73 | $this->assertSame('transactionstatus', $payment->getTransactionStatus()); |
||
74 | $this->assertSame('reasoncode', $payment->getReasonCode()); |
||
75 | $this->assertSame(208, $payment->getMerchantCurrency()); |
||
76 | $this->assertSame('DKK', $payment->getMerchantCurrencyAlpha()); |
||
77 | $this->assertSame(700, $payment->getCardHolderCurrency()); |
||
78 | $this->assertSame('EUR', $payment->getCardHolderCurrencyAlpha()); |
||
79 | $this->assertEquals($reservedAmount, $payment->getReservedAmount()); |
||
80 | $this->assertEquals($capturedAmount, $payment->getCapturedAmount()); |
||
81 | $this->assertEquals($refundedAmount, $payment->getRefundedAmount()); |
||
82 | $this->assertEquals($recurringDefaultAmount, $payment->getRecurringDefaultAmount()); |
||
83 | $this->assertSame($created, $payment->getCreatedDate()); |
||
84 | $this->assertSame($updated, $payment->getUpdatedDate()); |
||
85 | $this->assertSame('paymentnature', $payment->getPaymentNature()); |
||
86 | $this->assertSame(false, $payment->getSupportsRefunds()); |
||
87 | $this->assertSame(false, $payment->getSupportsRelease()); |
||
88 | $this->assertSame(true, $payment->getSupportsMultipleCaptures()); |
||
89 | $this->assertSame(true, $payment->getSupportsMultipleRefunds()); |
||
90 | $this->assertSame(13.37, $payment->getFraudRiskScore()); |
||
91 | $this->assertSame('fraudexplanation', $payment->getFraudExplanation()); |
||
92 | $this->assertEquals($totalAmount, $payment->getTotalAmount()); |
||
93 | $this->assertEquals($shippingFee, $payment->getShippingFee()); |
||
94 | $this->assertEquals($paymentFee, $payment->getPaymentFee()); |
||
95 | } |
||
96 | |||
97 | public function testCurrencyIsNull() |
||
98 | { |
||
99 | $payment = new Payment(); |
||
100 | $this->assertSame(null, $payment->getTotalAmount()); |
||
101 | } |
||
102 | |||
103 | public function testCreatePaymentLine() |
||
104 | { |
||
105 | $price = new Money(100, new Currency('DKK')); |
||
106 | $paymentLine = Payment::createPaymentLine('product_number', 'name', 1, $price, 25); |
||
107 | |||
108 | $this->assertInstanceOf(PaymentLine::class, $paymentLine); |
||
109 | $this->assertSame('product_number', $paymentLine->getProductNumber()); |
||
110 | $this->assertSame('name', $paymentLine->getName()); |
||
111 | $this->assertSame(1, $paymentLine->getQuantity()); |
||
112 | $this->assertEquals($price, $paymentLine->getPrice()); |
||
113 | $this->assertSame(25, $paymentLine->getVat()); |
||
114 | } |
||
115 | |||
116 | View Code Duplication | public function testIsCaptureable1() |
|
0 ignored issues
–
show
|
|||
117 | { |
||
118 | $payment = new Payment(); |
||
119 | |||
120 | $payment |
||
121 | ->setReservedAmount(new Money(10000, new Currency('DKK'))) |
||
122 | ->setCapturedAmount(new Money(10000, new Currency('DKK'))) |
||
123 | ->setRefundedAmount(new Money(0, new Currency('DKK'))) |
||
124 | ->setCurrencySymbol('DKK') |
||
125 | ; |
||
126 | |||
127 | $this->assertSame(false, $payment->isCaptureable()); |
||
128 | } |
||
129 | |||
130 | View Code Duplication | public function testIsCaptureable2() |
|
0 ignored issues
–
show
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. ![]() |
|||
131 | { |
||
132 | $payment = new Payment(); |
||
133 | |||
134 | $payment |
||
135 | ->setReservedAmount(new Money(10000, new Currency('DKK'))) |
||
136 | ->setCapturedAmount(new Money(1000, new Currency('DKK'))) |
||
137 | ->setRefundedAmount(new Money(0, new Currency('DKK'))) |
||
138 | ->setSupportsMultipleCaptures(false) |
||
139 | ->setCurrencySymbol('DKK') |
||
140 | ; |
||
141 | |||
142 | $this->assertSame(false, $payment->isCaptureable()); |
||
143 | } |
||
144 | |||
145 | View Code Duplication | public function testIsCaptureable3() |
|
0 ignored issues
–
show
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. ![]() |
|||
146 | { |
||
147 | $payment = new Payment(); |
||
148 | |||
149 | $payment |
||
150 | ->setReservedAmount(new Money(10000, new Currency('DKK'))) |
||
151 | ->setCapturedAmount(new Money(0, new Currency('DKK'))) |
||
152 | ->setRefundedAmount(new Money(0, new Currency('DKK'))) |
||
153 | ->setCurrencySymbol('DKK') |
||
154 | ; |
||
155 | |||
156 | $this->assertSame(true, $payment->isCaptureable()); |
||
157 | } |
||
158 | |||
159 | View Code Duplication | public function testIsRefundable1() |
|
0 ignored issues
–
show
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. ![]() |
|||
160 | { |
||
161 | $payment = new Payment(); |
||
162 | |||
163 | $payment |
||
164 | ->setCapturedAmount(new Money(10000, new Currency('DKK'))) |
||
165 | ->setRefundedAmount(new Money(10000, new Currency('DKK'))) |
||
166 | ->setCurrencySymbol('DKK') |
||
167 | ; |
||
168 | |||
169 | $this->assertSame(false, $payment->isRefundable()); |
||
170 | } |
||
171 | |||
172 | View Code Duplication | public function testIsRefundable2() |
|
0 ignored issues
–
show
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. ![]() |
|||
173 | { |
||
174 | $payment = new Payment(); |
||
175 | |||
176 | $payment |
||
177 | ->setCapturedAmount(new Money(10000, new Currency('DKK'))) |
||
178 | ->setRefundedAmount(new Money(5000, new Currency('DKK'))) |
||
179 | ->setSupportsMultipleRefunds(false) |
||
180 | ->setCurrencySymbol('DKK') |
||
181 | ; |
||
182 | |||
183 | $this->assertSame(false, $payment->isRefundable()); |
||
184 | } |
||
185 | |||
186 | View Code Duplication | public function testIsRefundable3() |
|
0 ignored issues
–
show
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. ![]() |
|||
187 | { |
||
188 | $payment = new Payment(); |
||
189 | |||
190 | $payment |
||
191 | ->setCapturedAmount(new Money(10000, new Currency('DKK'))) |
||
192 | ->setRefundedAmount(new Money(0, new Currency('DKK'))) |
||
193 | ->setCurrencySymbol('DKK') |
||
194 | ; |
||
195 | |||
196 | $this->assertSame(true, $payment->isRefundable()); |
||
197 | } |
||
198 | } |
||
199 |
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.