|
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\Action; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusQuadPayPlugin\Action\CaptureAction; |
|
16
|
|
|
use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClientInterface; |
|
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\Reply\HttpRedirect; |
|
23
|
|
|
use Payum\Core\Request\Capture; |
|
24
|
|
|
use Payum\Core\Security\TokenInterface; |
|
25
|
|
|
use PhpSpec\ObjectBehavior; |
|
26
|
|
|
use Sylius\Component\Core\Model\PaymentInterface; |
|
27
|
|
|
|
|
28
|
|
|
final class CaptureActionSpec extends ObjectBehavior |
|
29
|
|
|
{ |
|
30
|
|
|
function it_is_initializable(): void |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$this->shouldHaveType(CaptureAction::class); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_implements_action_interface(): void |
|
36
|
|
|
{ |
|
37
|
|
|
$this->shouldHaveType(ActionInterface::class); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function it_implements_api_aware_interface(): void |
|
41
|
|
|
{ |
|
42
|
|
|
$this->shouldHaveType(ApiAwareInterface::class); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_implements_gateway_aware_interface(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->shouldHaveType(GatewayAwareInterface::class); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
function it_executes( |
|
51
|
|
|
Capture $request, |
|
52
|
|
|
ArrayObject $arrayObject, |
|
53
|
|
|
PaymentInterface $payment, |
|
54
|
|
|
TokenInterface $token, |
|
55
|
|
|
GatewayInterface $gateway, |
|
56
|
|
|
QuadPayApiClientInterface $quadPayApiClient |
|
57
|
|
|
): void { |
|
58
|
|
|
$this->setGateway($gateway); |
|
|
|
|
|
|
59
|
|
|
$quadPayApiClient->createOrder([])->willReturn(['token' => 'test', 'redirectUrl' => 'test']); |
|
60
|
|
|
$this->setApi($quadPayApiClient); |
|
|
|
|
|
|
61
|
|
|
$token->getTargetUrl()->willReturn('url'); |
|
62
|
|
|
$arrayObject->getArrayCopy()->willReturn([]); |
|
63
|
|
|
$request->getModel()->willReturn($arrayObject); |
|
64
|
|
|
$request->getFirstModel()->willReturn($payment); |
|
65
|
|
|
$request->getToken()->willReturn($token); |
|
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
$arrayObject->offsetExists('orderToken')->shouldBeCalled(); |
|
68
|
|
|
$arrayObject->offsetSet('merchant', ['redirectConfirmUrl' => 'url', 'redirectCancelUrl' => 'url?&status=abandoned'])->shouldBeCalled(); |
|
|
|
|
|
|
69
|
|
|
$arrayObject->offsetSet('orderToken', 'test')->shouldBeCalled(); |
|
|
|
|
|
|
70
|
|
|
$arrayObject->offsetSet('orderStatus', 'created')->shouldBeCalled(); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
$this |
|
73
|
|
|
->shouldThrow(HttpRedirect::class) |
|
74
|
|
|
->during('execute', [$request]) |
|
75
|
|
|
; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
function it_supports_only_capture_request_and_array_access( |
|
79
|
|
|
Capture $request, |
|
80
|
|
|
\ArrayAccess $arrayAccess |
|
81
|
|
|
): void { |
|
82
|
|
|
$request->getModel()->willReturn($arrayAccess); |
|
83
|
|
|
|
|
84
|
|
|
$this->supports($request)->shouldReturn(true); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
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.