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

it_executes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
cc 1
eloc 11
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\StateMachine;
14
15
use BitBag\SyliusMolliePlugin\Action\Api\BaseApiAwareAction;
16
use BitBag\SyliusMolliePlugin\Action\StateMachine\StatusRecurringSubscriptionAction;
17
use BitBag\SyliusMolliePlugin\Client\MollieApiClient;
18
use BitBag\SyliusMolliePlugin\Entity\SubscriptionInterface;
19
use BitBag\SyliusMolliePlugin\Request\StateMachine\StatusRecurringSubscription;
20
use BitBag\SyliusMolliePlugin\Transitions\SubscriptionTransitions;
21
use Doctrine\ORM\EntityManagerInterface;
22
use Payum\Core\Action\ActionInterface;
23
use Payum\Core\ApiAwareInterface;
24
use PhpSpec\ObjectBehavior;
25
use SM\Factory\FactoryInterface;
26
use SM\StateMachine\StateMachineInterface;
27
28
final class StatusRecurringSubscriptionActionSpec extends ObjectBehavior
29
{
30
    function let(
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...
31
        EntityManagerInterface $subscriptionManager,
32
        FactoryInterface $subscriptionSateMachineFactory
33
    ): void {
34
        $this->beConstructedWith(
35
            $subscriptionManager,
36
            $subscriptionSateMachineFactory
37
        );
38
    }
39
40
    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...
41
    {
42
        $this->shouldHaveType(StatusRecurringSubscriptionAction::class);
43
    }
44
45
    function it_implements_action_interface(): void
46
    {
47
        $this->shouldHaveType(ActionInterface::class);
48
    }
49
50
    function it_implements_api_aware_interface(): void
51
    {
52
        $this->shouldHaveType(ApiAwareInterface::class);
53
    }
54
55
    function it_extends_base_api_aware(): void
56
    {
57
        $this->shouldHaveType(BaseApiAwareAction::class);
58
    }
59
60
    function it_executes(
61
        StatusRecurringSubscription $request,
62
        MollieApiClient $mollieApiClient,
63
        SubscriptionInterface $subscription,
64
        \Mollie_API_Resource_Customers_Subscriptions $subscriptions,
65
        \Mollie_API_Object_Customer_Subscription $customerSubscription,
66
        FactoryInterface $subscriptionSateMachineFactory,
67
        StateMachineInterface $stateMachine,
68
        \Mollie_API_Resource_Base $resourceBase
69
    ): void {
70
        $this->setApi($mollieApiClient);
0 ignored issues
show
Bug introduced by
The method setApi() does not exist on spec\BitBag\SyliusMollie...gSubscriptionActionSpec. 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

70
        $this->/** @scrutinizer ignore-call */ 
71
               setApi($mollieApiClient);
Loading history...
71
        $stateMachine->can(SubscriptionTransitions::TRANSITION_ACTIVATE)->willReturn();
72
        $customerSubscription->status = \Mollie_API_Object_Customer_Subscription::STATUS_ACTIVE;
73
        $subscriptionSateMachineFactory->get($subscription, SubscriptionTransitions::GRAPH)->willReturn($stateMachine);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on SM\StateMachine\StateMachineInterface. ( Ignorable by Annotation )

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

73
        $subscriptionSateMachineFactory->get($subscription, SubscriptionTransitions::GRAPH)->/** @scrutinizer ignore-call */ willReturn($stateMachine);

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...
74
        $subscription->getSubscriptionId()->willReturn('id_1');
75
        $subscription->getCustomerId()->willReturn('id_1');
76
        $resourceBase->get('id_1')->willReturn($customerSubscription);
77
        $subscriptions->withParentId('id_1')->willReturn($resourceBase);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Mollie_API_Resource_Customers_Subscriptions. ( Ignorable by Annotation )

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

77
        $subscriptions->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...
78
        $mollieApiClient->customers_subscriptions = $subscriptions;
79
        $request->getModel()->willReturn($subscription);
80
81
        $this->execute($request);
0 ignored issues
show
Bug introduced by
The method execute() does not exist on spec\BitBag\SyliusMollie...gSubscriptionActionSpec. 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

81
        $this->/** @scrutinizer ignore-call */ 
82
               execute($request);
Loading history...
82
    }
83
84
    function it_supports_status_recurring_subscription_request_and_subscription_model(
85
        StatusRecurringSubscription $request,
86
        SubscriptionInterface $subscription
87
    ): void {
88
        $request->getModel()->willReturn($subscription);
89
90
        $this->supports($request)->shouldReturn(true);
0 ignored issues
show
Bug introduced by
The method supports() does not exist on spec\BitBag\SyliusMollie...gSubscriptionActionSpec. 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
               supports($request)->shouldReturn(true);
Loading history...
91
    }
92
}
93