Completed
Push — 1.0 ( c43d89...ceb5fb )
by Kamil
69:26 queued 21:22
created

ConvertPaymentActionSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 47
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_payum_action() 0 4 1
A it_converts_payment_to_offline_action() 0 11 1
A it_supports_only_convert_request() 0 11 1
A it_supports_only_converting_to_array_from_payment() 0 15 1
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