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

it_extends_gateway_aware_action()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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