1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace spec\BitBag\SyliusQuadPayPlugin\PaymentProcessing; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClientInterface; |
16
|
|
|
use BitBag\SyliusQuadPayPlugin\PaymentProcessing\PaymentProcessorInterface; |
17
|
|
|
use BitBag\SyliusQuadPayPlugin\PaymentProcessing\RefundPaymentProcessor; |
18
|
|
|
use BitBag\SyliusQuadPayPlugin\QuadPayGatewayFactory; |
19
|
|
|
use Payum\Core\Model\GatewayConfigInterface; |
20
|
|
|
use PhpSpec\ObjectBehavior; |
21
|
|
|
use Prophecy\Argument; |
22
|
|
|
use Sylius\Component\Core\Model\PaymentInterface; |
23
|
|
|
use Sylius\Component\Core\Model\PaymentMethodInterface; |
24
|
|
|
use Symfony\Component\HttpFoundation\Session\Session; |
25
|
|
|
|
26
|
|
|
final class RefundPaymentProcessorSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function let(Session $session, QuadPayApiClientInterface $quadPayApiClient): void |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$this->beConstructedWith($session, $quadPayApiClient); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_is_initializable(): void |
|
|
|
|
34
|
|
|
{ |
35
|
|
|
$this->shouldHaveType(RefundPaymentProcessor::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_implements_payment_processor_interface(): void |
39
|
|
|
{ |
40
|
|
|
$this->shouldHaveType(PaymentProcessorInterface::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function it_processes( |
44
|
|
|
PaymentInterface $payment, |
45
|
|
|
PaymentMethodInterface $paymentMethod, |
46
|
|
|
GatewayConfigInterface $gatewayConfig, |
47
|
|
|
QuadPayApiClientInterface $quadPayApiClient |
48
|
|
|
): void { |
49
|
|
|
$gatewayConfig->getFactoryName()->willReturn(QuadPayGatewayFactory::FACTORY_NAME); |
|
|
|
|
50
|
|
|
$gatewayConfig->getConfig()->willReturn([ |
51
|
|
|
'clientId' => 'test', |
52
|
|
|
'clientSecret' => 'test', |
53
|
|
|
'apiEndpoint' => 'https://api-ci.quadpay.com/', |
54
|
|
|
'authTokenEndpoint' => 'https://api-ci.quadpay.com/', |
55
|
|
|
'apiAudience' => 'https://api-ci.quadpay.com/', |
56
|
|
|
]); |
57
|
|
|
$paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); |
|
|
|
|
58
|
|
|
$payment->getMethod()->willReturn($paymentMethod); |
|
|
|
|
59
|
|
|
$payment->getAmount()->willReturn(222222); |
60
|
|
|
$payment->getDetails()->willReturn([ |
61
|
|
|
'orderToken' => 'test', |
62
|
|
|
]); |
63
|
|
|
/** @var string|array $argumentAny */ |
64
|
|
|
$argumentAny = Argument::any(); |
65
|
|
|
$quadPayApiClient->setConfig( |
66
|
|
|
'test', |
67
|
|
|
'test', |
68
|
|
|
'https://api-ci.quadpay.com/', |
69
|
|
|
'https://api-ci.quadpay.com/', |
70
|
|
|
'https://api-ci.quadpay.com/' |
71
|
|
|
); |
72
|
|
|
$quadPayApiClient->refund(2222.22, $argumentAny, 'test', null)->willReturn(['refundId' => 'test']); |
|
|
|
|
73
|
|
|
|
74
|
|
|
$payment->setDetails($argumentAny)->shouldBeCalled(); |
|
|
|
|
75
|
|
|
|
76
|
|
|
$this->process($payment); |
|
|
|
|
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.