|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Sylius\Bundle\PayumBundle\Action; |
|
4
|
|
|
|
|
5
|
|
|
use Payum\Core\Action\GatewayAwareAction; |
|
6
|
|
|
use Payum\Core\Bridge\Spl\ArrayObject; |
|
7
|
|
|
use Payum\Core\GatewayInterface; |
|
8
|
|
|
use Payum\Core\Request\Capture; |
|
9
|
|
|
use PhpSpec\ObjectBehavior; |
|
10
|
|
|
use Prophecy\Argument; |
|
11
|
|
|
use Sylius\Bundle\PayumBundle\Action\CapturePaymentAction; |
|
12
|
|
|
use Sylius\Bundle\PayumBundle\Provider\PaymentDescriptionProviderInterface; |
|
13
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
|
14
|
|
|
use Sylius\Component\Core\Model\PaymentInterface; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @author Stefan Doorn <[email protected]> |
|
18
|
|
|
*/ |
|
19
|
|
|
final class CapturePaymentActionSpec extends ObjectBehavior |
|
20
|
|
|
{ |
|
21
|
|
|
function let(PaymentDescriptionProviderInterface $paymentDescriptionProvider) |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
$this->beConstructedWith($paymentDescriptionProvider); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
function it_is_initializable() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->shouldHaveType(CapturePaymentAction::class); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function it_extends_gateway_aware_action() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->shouldHaveType(GatewayAwareAction::class); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_should_throw_exception_when_unsupported_request(Capture $capture) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->shouldThrow('\Payum\Core\Exception\RequestNotSupportedException')->duringExecute($capture); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_should_perform_basic_capture( |
|
42
|
|
|
PaymentDescriptionProviderInterface $paymentDescriptionProvider, |
|
|
|
|
|
|
43
|
|
|
GatewayInterface $gateway, |
|
44
|
|
|
Capture $capture, |
|
45
|
|
|
PaymentInterface $payment, |
|
46
|
|
|
OrderInterface $order |
|
47
|
|
|
) { |
|
48
|
|
|
$this->setGateway($gateway); |
|
49
|
|
|
|
|
50
|
|
|
$payment->getOrder()->willReturn($order); |
|
51
|
|
|
$payment->getDetails()->willReturn([]); |
|
52
|
|
|
$capture->getModel()->willReturn($payment); |
|
53
|
|
|
|
|
54
|
|
|
$payment->setDetails([])->shouldBeCalled(); |
|
55
|
|
|
$capture->setModel(new ArrayObject())->shouldBeCalled(); |
|
56
|
|
|
|
|
57
|
|
|
$this->execute($capture); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.