Completed
Push — allow-no-default-tax-zone-in-c... ( 67cea0 )
by Kamil
06:23
created

AuthorizePaymentActionSpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_extends_gateway_aware_action() 0 4 1
A it_should_throw_exception_when_unsupported_request() 0 4 1
A it_should_perform_basic_authorize() 0 14 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;
15
16
use Payum\Core\Action\GatewayAwareAction;
17
use Payum\Core\Bridge\Spl\ArrayObject;
18
use Payum\Core\Exception\RequestNotSupportedException;
19
use Payum\Core\GatewayInterface;
20
use Payum\Core\Request\Authorize;
21
use PhpSpec\ObjectBehavior;
22
use Sylius\Bundle\PayumBundle\Provider\PaymentDescriptionProviderInterface;
23
use Sylius\Component\Core\Model\OrderInterface;
24
use Sylius\Component\Core\Model\PaymentInterface;
25
26
final class AuthorizePaymentActionSpec extends ObjectBehavior
27
{
28
    function let(PaymentDescriptionProviderInterface $paymentDescriptionProvider): void
29
    {
30
        $this->beConstructedWith($paymentDescriptionProvider);
31
    }
32
33
    function it_extends_gateway_aware_action(): void
34
    {
35
        $this->shouldHaveType(GatewayAwareAction::class);
36
    }
37
38
    function it_should_throw_exception_when_unsupported_request(Authorize $authorize): void
39
    {
40
        $this->shouldThrow(RequestNotSupportedException::class)->duringExecute($authorize);
41
    }
42
43
    function it_should_perform_basic_authorize(
44
        GatewayInterface $gateway,
45
        Authorize $authorize,
46
        PaymentInterface $payment,
47
        OrderInterface $order
48
    ): void {
49
        $this->setGateway($gateway);
50
        $payment->getOrder()->willReturn($order);
51
        $payment->getDetails()->willReturn([]);
52
        $authorize->getModel()->willReturn($payment);
53
        $payment->setDetails([])->shouldBeCalled();
54
        $authorize->setModel(new ArrayObject())->shouldBeCalled();
55
        $this->execute($authorize);
56
    }
57
}
58