|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\PayumBundle\Action\Offline; |
|
15
|
|
|
|
|
16
|
|
|
use Payum\Core\Action\ActionInterface; |
|
17
|
|
|
use Payum\Core\Model\PaymentInterface; |
|
18
|
|
|
use Payum\Core\Request\Capture; |
|
19
|
|
|
use Payum\Core\Request\Convert; |
|
20
|
|
|
use Payum\Offline\Constants; |
|
21
|
|
|
use PhpSpec\ObjectBehavior; |
|
22
|
|
|
use Sylius\Component\Payment\Model\PaymentMethodInterface; |
|
23
|
|
|
|
|
24
|
|
|
final class ConvertPaymentActionSpec extends ObjectBehavior |
|
25
|
|
|
{ |
|
26
|
|
|
function it_is_payum_action(): void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->shouldImplement(ActionInterface::class); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function it_converts_payment_to_offline_action(Convert $request, PaymentInterface $payment): void |
|
32
|
|
|
{ |
|
33
|
|
|
$request->getTo()->willReturn('array'); |
|
34
|
|
|
$request->getSource()->willReturn($payment); |
|
35
|
|
|
|
|
36
|
|
|
$request->setResult([ |
|
37
|
|
|
Constants::FIELD_PAID => false, |
|
38
|
|
|
])->shouldBeCalled(); |
|
39
|
|
|
|
|
40
|
|
|
$this->execute($request); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function it_supports_only_convert_request( |
|
44
|
|
|
Convert $convertRequest, |
|
45
|
|
|
Capture $captureRequest, |
|
46
|
|
|
PaymentInterface $payment |
|
47
|
|
|
): void { |
|
48
|
|
|
$convertRequest->getTo()->willReturn('array'); |
|
49
|
|
|
$convertRequest->getSource()->willReturn($payment); |
|
50
|
|
|
|
|
51
|
|
|
$this->supports($convertRequest)->shouldReturn(true); |
|
52
|
|
|
$this->supports($captureRequest)->shouldReturn(false); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function it_supports_only_converting_to_array_from_payment( |
|
56
|
|
|
Convert $fromSomethingElseToSomethingElseRequest, |
|
57
|
|
|
Convert $fromPaymentToArrayRequest, |
|
58
|
|
|
PaymentInterface $payment, |
|
59
|
|
|
PaymentMethodInterface $method |
|
60
|
|
|
): void { |
|
61
|
|
|
$fromPaymentToArrayRequest->getTo()->willReturn('array'); |
|
62
|
|
|
$fromPaymentToArrayRequest->getSource()->willReturn($payment); |
|
63
|
|
|
|
|
64
|
|
|
$fromSomethingElseToSomethingElseRequest->getTo()->willReturn('json'); |
|
65
|
|
|
$fromSomethingElseToSomethingElseRequest->getSource()->willReturn($method); |
|
66
|
|
|
|
|
67
|
|
|
$this->supports($fromPaymentToArrayRequest)->shouldReturn(true); |
|
68
|
|
|
$this->supports($fromSomethingElseToSomethingElseRequest)->shouldReturn(false); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|