Passed
Push — master ( 2bdea1...160902 )
by Mikołaj
05:53
created

CreateSepaMandateActionSpec::it_executes()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 8

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace spec\BitBag\SyliusMolliePlugin\Action\Api;
14
15
use BitBag\SyliusMolliePlugin\Action\Api\BaseApiAwareAction;
16
use BitBag\SyliusMolliePlugin\Action\Api\CreateSepaMandateAction;
17
use BitBag\SyliusMolliePlugin\Client\MollieApiClient;
18
use BitBag\SyliusMolliePlugin\Request\Api\CreateSepaMandate;
19
use Payum\Core\Action\ActionInterface;
20
use Payum\Core\ApiAwareInterface;
21
use Payum\Core\Bridge\Spl\ArrayObject;
22
use Payum\Core\GatewayAwareInterface;
23
use Payum\Core\GatewayInterface;
24
use PhpSpec\ObjectBehavior;
25
use Symfony\Component\HttpFoundation\Session\SessionInterface;
26
27
final class CreateSepaMandateActionSpec extends ObjectBehavior
28
{
29
    function let(SessionInterface $session): void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
30
    {
31
        $this->beConstructedWith(
32
            $session
33
        );
34
    }
35
36
    function it_is_initializable(): void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
37
    {
38
        $this->shouldHaveType(CreateSepaMandateAction::class);
39
    }
40
41
    function it_implements_action_interface(): void
42
    {
43
        $this->shouldHaveType(ActionInterface::class);
44
    }
45
46
    function it_implements_api_aware_interface(): void
47
    {
48
        $this->shouldHaveType(ApiAwareInterface::class);
49
    }
50
51
    function it_implements_gateway_aware_interface(): void
52
    {
53
        $this->shouldHaveType(GatewayAwareInterface::class);
54
    }
55
56
    function it_extends_base_api_aware(): void
57
    {
58
        $this->shouldHaveType(BaseApiAwareAction::class);
59
    }
60
61
    function it_executes(
62
        CreateSepaMandate $request,
63
        MollieApiClient $mollieApiClient,
64
        ArrayObject $arrayObject,
65
        GatewayInterface $gateway,
66
        SessionInterface $session,
67
        \Mollie_API_Resource_Customers_Mandates $customersMandates,
68
        \Mollie_API_Resource_Base $resourceBase,
69
        \Mollie_API_Object_Customer_Mandate $customerMandate
70
    ): void {
71
        $this->setApi($mollieApiClient);
0 ignored issues
show
Bug introduced by
The method setApi() does not exist on spec\BitBag\SyliusMollie...teSepaMandateActionSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
        $this->/** @scrutinizer ignore-call */ 
72
               setApi($mollieApiClient);
Loading history...
72
        $this->setGateway($gateway);
0 ignored issues
show
Bug introduced by
The method setGateway() does not exist on spec\BitBag\SyliusMollie...teSepaMandateActionSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

72
        $this->/** @scrutinizer ignore-call */ 
73
               setGateway($gateway);
Loading history...
73
        $mollieApiClient->customers_mandates = $customersMandates;
74
        $customerMandate->id = 'id_1';
75
        $resourceBase->create([
76
            'consumerAccount' => '57357086404',
77
            'consumerName' => 'Example',
78
            'method' => 'directdebit',
79
        ])->willReturn($customerMandate);
80
        $customersMandates->withParentId('id_1')->willReturn($resourceBase);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Mollie_API_Resource_Customers_Mandates. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

80
        $customersMandates->withParentId('id_1')->/** @scrutinizer ignore-call */ willReturn($resourceBase);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
81
        $session->get('mollie_direct_debit_data', null)->willReturn([
82
            'iban' => '57357086404',
83
            'consumerName' => 'Example',
84
        ]);
85
        $arrayObject->offsetGet('customer_mollie_id')->willReturn('id_1');
86
        $request->getModel()->willReturn($arrayObject);
87
88
        $arrayObject->offsetSet('mandate_mollie_id', 'id_1')->shouldBeCalled();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $arrayObject->offsetSet(...ate_mollie_id', 'id_1') targeting Payum\Core\Bridge\Spl\ArrayObject::offsetSet() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
89
90
        $this->execute($request);
0 ignored issues
show
Bug introduced by
The method execute() does not exist on spec\BitBag\SyliusMollie...teSepaMandateActionSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
        $this->/** @scrutinizer ignore-call */ 
91
               execute($request);
Loading history...
91
    }
92
93
    function it_supports_only_create_sepa_mandate_request_and_array_access(
94
        CreateSepaMandate $request,
95
        \ArrayAccess $arrayAccess
96
    ): void {
97
        $request->getModel()->willReturn($arrayAccess);
98
99
        $this->supports($request)->shouldReturn(true);
0 ignored issues
show
Bug introduced by
The method supports() does not exist on spec\BitBag\SyliusMollie...teSepaMandateActionSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

99
        $this->/** @scrutinizer ignore-call */ 
100
               supports($request)->shouldReturn(true);
Loading history...
100
    }
101
}
102