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\SyliusMolliePlugin\Action; |
14
|
|
|
|
15
|
|
|
use BitBag\SyliusMolliePlugin\Action\RefundAction; |
16
|
|
|
use BitBag\SyliusMolliePlugin\Client\MollieApiClient; |
17
|
|
|
use Payum\Core\Action\ActionInterface; |
18
|
|
|
use Payum\Core\ApiAwareInterface; |
19
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
20
|
|
|
use Payum\Core\GatewayAwareInterface; |
21
|
|
|
use Payum\Core\GatewayInterface; |
22
|
|
|
use Payum\Core\Request\Refund; |
23
|
|
|
use PhpSpec\ObjectBehavior; |
24
|
|
|
|
25
|
|
|
final class RefundActionSpec extends ObjectBehavior |
26
|
|
|
{ |
27
|
|
|
function it_is_initializable(): void |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$this->shouldHaveType(RefundAction::class); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function it_implements_action_interface(): void |
33
|
|
|
{ |
34
|
|
|
$this->shouldHaveType(ActionInterface::class); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
function it_implements_api_aware_interface(): void |
38
|
|
|
{ |
39
|
|
|
$this->shouldHaveType(ApiAwareInterface::class); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
function it_implements_gateway_aware_interface(): void |
43
|
|
|
{ |
44
|
|
|
$this->shouldHaveType(GatewayAwareInterface::class); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
function it_executes( |
48
|
|
|
Refund $request, |
49
|
|
|
GatewayInterface $gateway, |
50
|
|
|
MollieApiClient $mollieApiClient |
51
|
|
|
): void { |
52
|
|
|
$this->setGateway($gateway); |
|
|
|
|
53
|
|
|
$this->setApi($mollieApiClient); |
|
|
|
|
54
|
|
|
$arrayObject = new ArrayObject(['payment_mollie_id' => 1]); |
55
|
|
|
$request->getModel()->willReturn($arrayObject); |
56
|
|
|
$payment = \Mockery::mock('payment'); |
57
|
|
|
$payment->shouldReceive('canBeRefunded')->andReturn(true); |
58
|
|
|
$payment->shouldReceive('refund')->andReturn(true); |
59
|
|
|
$payment->shouldReceive('get')->andReturn($payment); |
60
|
|
|
|
61
|
|
|
$mollieApiClient->payments = $payment; |
|
|
|
|
62
|
|
|
|
63
|
|
|
$this->execute($request); |
|
|
|
|
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
function it_supports_only_refund_request_and_array_access( |
67
|
|
|
Refund $request, |
68
|
|
|
\ArrayAccess $arrayAccess |
69
|
|
|
): void { |
70
|
|
|
$request->getModel()->willReturn($arrayAccess); |
71
|
|
|
|
72
|
|
|
$this->supports($request)->shouldReturn(true); |
|
|
|
|
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
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.