Completed
Push — core-test-reorganisation ( 880d88 )
by Kamil
44:19 queued 07:25
created

PaymentMethodNameToGatewayConverterSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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
namespace spec\Sylius\Behat\Service;
13
14
use Payum\Core\GatewayInterface;
15
use Payum\Core\Registry\RegistryInterface;
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Behat\Service\PaymentMethodNameToGatewayConverter;
18
use Sylius\Behat\Service\PaymentMethodNameToGatewayConverterInterface;
19
20
/**
21
 * @author Arkadiusz Krakowiak <[email protected]>
22
 */
23
final class PaymentMethodNameToGatewayConverterSpec extends ObjectBehavior
24
{
25
    function let(RegistryInterface $payum)
26
    {
27
        $this->beConstructedWith($payum);
28
    }
29
30
    function it_is_initializable()
31
    {
32
        $this->shouldHaveType(PaymentMethodNameToGatewayConverter::class);
33
    }
34
35
    function it_implements_payment_method_name_to_gateway_converter_interface()
36
    {
37
        $this->shouldImplement(PaymentMethodNameToGatewayConverterInterface::class);
38
    }
39
40
    function it_converts_payment_method_name_to_gateway($payum, GatewayInterface $offlineGateway, GatewayInterface $paypalCheckoutExpressGateway)
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $paypalCheckoutExpressGateway exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
41
    {
42
        $gateways = [
43
            'offline' => $offlineGateway,
44
            'paypal_checkout_express' => $paypalCheckoutExpressGateway,
45
        ];
46
        $payum->getGateways()->willReturn($gateways);
47
48
        $this->convert('offline')->shouldReturn('offline');
49
50
        $this->convert('Paypal Checkout Express')->shouldReturn('paypal_checkout_express');
51
    }
52
53
    function it_throws_exception_when_cannot_map_gateway($payum, GatewayInterface $paypalCheckoutExpressGateway)
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $paypalCheckoutExpressGateway exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
54
    {
55
        $gateways = [
56
            'paypal_checkout_express' => $paypalCheckoutExpressGateway,
57
        ];
58
        $payum->getGateways()->willReturn($gateways);
59
60
        $this->shouldThrow(new \RuntimeException('Cannot convert offline to gateway'))->during('convert', ['offline']);
61
    }
62
63
    function it_throws_exception_when_given_name_is_null()
64
    {
65
        $this->shouldThrow(new \InvalidArgumentException('Payment method name cannot be null'))->during('convert', ['']);
66
    }
67
}
68