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

it_implements_api_aware_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
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;
14
15
use BitBag\SyliusMolliePlugin\Action\NotifyAction;
16
use BitBag\SyliusMolliePlugin\Client\MollieApiClient;
17
use BitBag\SyliusMolliePlugin\Repository\SubscriptionRepositoryInterface;
18
use Payum\Core\Action\ActionInterface;
19
use Payum\Core\ApiAwareInterface;
20
use Payum\Core\GatewayAwareInterface;
21
use Payum\Core\GatewayInterface;
22
use Payum\Core\Request\GetHttpRequest;
23
use Payum\Core\Request\Notify;
24
use PhpSpec\ObjectBehavior;
25
26
final class NotifyActionSpec extends ObjectBehavior
27
{
28
    function let(GetHttpRequest $getHttpRequest, SubscriptionRepositoryInterface $subscriptionRepository): 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...
29
    {
30
        $this->beConstructedWith($getHttpRequest, $subscriptionRepository);
31
    }
32
33
    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...
34
    {
35
        $this->shouldHaveType(NotifyAction::class);
36
    }
37
38
    function it_implements_action_interface(): void
39
    {
40
        $this->shouldHaveType(ActionInterface::class);
41
    }
42
43
    function it_implements_api_aware_interface(): void
44
    {
45
        $this->shouldHaveType(ApiAwareInterface::class);
46
    }
47
48
    function it_implements_gateway_aware_interface(): void
49
    {
50
        $this->shouldHaveType(GatewayAwareInterface::class);
51
    }
52
53
    function it_executes(
54
        Notify $request,
55
        \ArrayObject $arrayObject,
56
        GatewayInterface $gateway,
57
        GetHttpRequest $getHttpRequest,
58
        MollieApiClient $mollieApiClient,
59
        \Mollie_API_Resource_Base $mollieApiResourceBase
60
    ): void {
61
        $this->setGateway($gateway);
0 ignored issues
show
Bug introduced by
The method setGateway() does not exist on spec\BitBag\SyliusMollie...Action\NotifyActionSpec. 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

61
        $this->/** @scrutinizer ignore-call */ 
62
               setGateway($gateway);
Loading history...
62
63
        $this->setApi($mollieApiClient);
0 ignored issues
show
Bug introduced by
The method setApi() does not exist on spec\BitBag\SyliusMollie...Action\NotifyActionSpec. 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

63
        $this->/** @scrutinizer ignore-call */ 
64
               setApi($mollieApiClient);
Loading history...
64
        $getHttpRequest->request = ['id' => 1];
65
        $request->getModel()->willReturn($arrayObject);
66
        $payment = \Mockery::mock('payment');
67
        $payment->id = 1;
0 ignored issues
show
Bug introduced by
Accessing id on the interface Mockery\MockInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
68
        $payment->metadata = (object) [
0 ignored issues
show
Bug introduced by
Accessing metadata on the interface Mockery\MockInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
69
            'order_id' => 1,
70
        ];
71
        $payment->shouldReceive('getPaymentUrl')->andReturn('');
72
        $mollieApiResourceBase->get(1)->willReturn($payment);
73
        $mollieApiClient->payments = $mollieApiResourceBase;
0 ignored issues
show
Documentation Bug introduced by
$mollieApiResourceBase is of type Mollie_API_Resource_Base, but the property $payments was declared to be of type Mollie_API_Resource_Payments. 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...
74
75
        $this->execute($request);
0 ignored issues
show
Bug introduced by
The method execute() does not exist on spec\BitBag\SyliusMollie...Action\NotifyActionSpec. 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

75
        $this->/** @scrutinizer ignore-call */ 
76
               execute($request);
Loading history...
76
    }
77
78
    function it_supports_only_notify_request_and_array_access(
79
        Notify $request,
80
        \ArrayAccess $arrayAccess
81
    ): void {
82
        $request->getModel()->willReturn($arrayAccess);
83
84
        $this->supports($request)->shouldReturn(true);
0 ignored issues
show
Bug introduced by
The method supports() does not exist on spec\BitBag\SyliusMollie...Action\NotifyActionSpec. 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

84
        $this->/** @scrutinizer ignore-call */ 
85
               supports($request)->shouldReturn(true);
Loading history...
85
    }
86
}
87