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

it_executes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 5
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\CancelRecurringSubscriptionAction;
17
use BitBag\SyliusMolliePlugin\Client\MollieApiClient;
18
use BitBag\SyliusMolliePlugin\Entity\SubscriptionInterface;
19
use BitBag\SyliusMolliePlugin\Request\Api\CancelRecurringSubscription;
20
use Payum\Core\Action\ActionInterface;
21
use Payum\Core\ApiAwareInterface;
22
use PhpSpec\ObjectBehavior;
23
24
final class CancelRecurringSubscriptionActionSpec extends ObjectBehavior
25
{
26
    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...
27
    {
28
        $this->shouldHaveType(CancelRecurringSubscriptionAction::class);
29
    }
30
31
    function it_implements_action_interface(): void
32
    {
33
        $this->shouldHaveType(ActionInterface::class);
34
    }
35
36
    function it_implements_api_aware_interface(): void
37
    {
38
        $this->shouldHaveType(ApiAwareInterface::class);
39
    }
40
41
    function it_extends_base_api_aware(): void
42
    {
43
        $this->shouldHaveType(BaseApiAwareAction::class);
44
    }
45
46
    function it_executes(
47
        CancelRecurringSubscription $request,
48
        MollieApiClient $mollieApiClient,
49
        SubscriptionInterface $subscription,
50
        \Mollie_API_Resource_Base $mollieApiResourceBase,
51
        \Mollie_API_Resource_Customers_Subscriptions $subscriptions
52
    ): void {
53
        $mollieApiClient->customers_subscriptions = $mollieApiResourceBase;
0 ignored issues
show
Documentation Bug introduced by
$mollieApiResourceBase is of type Mollie_API_Resource_Base, but the property $customers_subscriptions was declared to be of type Mollie_API_Resource_Customers_Subscriptions. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
54
        $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

54
        $this->/** @scrutinizer ignore-call */ 
55
               setApi($mollieApiClient);
Loading history...
55
        $mollieApiResourceBase->withParentId('id_1')->willReturn($subscriptions);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Mollie_API_Resource_Base. ( Ignorable by Annotation )

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

55
        $mollieApiResourceBase->withParentId('id_1')->/** @scrutinizer ignore-call */ willReturn($subscriptions);

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...
56
        $subscription->getSubscriptionId()->willReturn('id_1');
57
        $subscription->getCustomerId()->willReturn('id_1');
58
        $request->getModel()->willReturn($subscription);
59
60
        $subscriptions->cancel('id_1')->shouldBeCalled();
0 ignored issues
show
Bug introduced by
The method shouldBeCalled() does not exist on Mollie_API_Object_Customer_Subscription. ( Ignorable by Annotation )

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

60
        $subscriptions->cancel('id_1')->/** @scrutinizer ignore-call */ shouldBeCalled();

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...
61
62
        $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

62
        $this->/** @scrutinizer ignore-call */ 
63
               execute($request);
Loading history...
63
    }
64
65
    function it_supports_cancel_recurring_subscription_request_and_subscription_model(
66
        CancelRecurringSubscription $request,
67
        SubscriptionInterface $subscription
68
    ): void {
69
        $request->getModel()->willReturn($subscription);
70
71
        $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

71
        $this->/** @scrutinizer ignore-call */ 
72
               supports($request)->shouldReturn(true);
Loading history...
72
    }
73
}
74