Completed
Push — npm-shrinkwrap ( 52ca24 )
by Kamil
23:13
created

PaymentMethodFactorySpec   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
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_is_initializable() 0 4 1
A it_implements_payment_method_factory_interface() 0 4 1
A it_creates_payment_method_with_specific_gateway() 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
namespace spec\Sylius\Component\Core\Factory;
13
14
use Payum\Core\Model\GatewayConfigInterface;
15
use PhpSpec\ObjectBehavior;
16
use Sylius\Component\Core\Factory\PaymentMethodFactory;
17
use Sylius\Component\Core\Factory\PaymentMethodFactoryInterface;
18
use Sylius\Component\Core\Model\PaymentMethodInterface;
19
use Sylius\Component\Resource\Factory\FactoryInterface;
20
21
/**
22
 * @author Mateusz Zalewski <[email protected]>
23
 */
24
final class PaymentMethodFactorySpec extends ObjectBehavior
25
{
26
    function let(FactoryInterface $decoratedFactory, FactoryInterface $gatewayConfigFactory)
27
    {
28
        $this->beConstructedWith($decoratedFactory, $gatewayConfigFactory);
29
    }
30
31
    function it_is_initializable()
32
    {
33
        $this->shouldHaveType(PaymentMethodFactory::class);
34
    }
35
36
    function it_implements_payment_method_factory_interface()
37
    {
38
        $this->shouldImplement(PaymentMethodFactoryInterface::class);
39
    }
40
41
    function it_creates_payment_method_with_specific_gateway(
42
        FactoryInterface $decoratedFactory,
43
        FactoryInterface $gatewayConfigFactory,
44
        GatewayConfigInterface $gatewayConfig,
45
        PaymentMethodInterface $paymentMethod
46
    ) {
47
        $gatewayConfigFactory->createNew()->willReturn($gatewayConfig);
48
        $gatewayConfig->setFactoryName('offline')->shouldBeCalled();
0 ignored issues
show
Deprecated Code introduced by
The method Payum\Core\Model\Gateway...rface::setFactoryName() has been deprecated with message: since 1.3.3 will be removed in 2.0. set factory option inside the config

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
49
50
        $decoratedFactory->createNew()->willReturn($paymentMethod);
51
        $paymentMethod->setGatewayConfig($gatewayConfig)->shouldBeCalled();
52
53
        $this->createWithGateway('offline');
54
    }
55
}
56