Issues (220)

spec/Action/Api/CreateSepaMandateActionSpec.php (9 issues)

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 Mollie\Api\Endpoints\CustomerEndpoint;
20
use Mollie\Api\Resources\Customer;
21
use Mollie\Api\Resources\Mandate;
22
use Payum\Core\Action\ActionInterface;
23
use Payum\Core\ApiAwareInterface;
24
use Payum\Core\Bridge\Spl\ArrayObject;
25
use Payum\Core\GatewayAwareInterface;
26
use Payum\Core\GatewayInterface;
27
use PhpSpec\ObjectBehavior;
28
use Symfony\Component\HttpFoundation\Session\SessionInterface;
29
30
final class CreateSepaMandateActionSpec extends ObjectBehavior
31
{
32
    function let(SessionInterface $session): void
0 ignored issues
show
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...
33
    {
34
        $this->beConstructedWith(
35
            $session
36
        );
37
    }
38
39
    function it_is_initializable(): void
0 ignored issues
show
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...
40
    {
41
        $this->shouldHaveType(CreateSepaMandateAction::class);
42
    }
43
44
    function it_implements_action_interface(): void
45
    {
46
        $this->shouldHaveType(ActionInterface::class);
47
    }
48
49
    function it_implements_api_aware_interface(): void
50
    {
51
        $this->shouldHaveType(ApiAwareInterface::class);
52
    }
53
54
    function it_implements_gateway_aware_interface(): void
55
    {
56
        $this->shouldHaveType(GatewayAwareInterface::class);
57
    }
58
59
    function it_extends_base_api_aware(): void
60
    {
61
        $this->shouldHaveType(BaseApiAwareAction::class);
62
    }
63
64
    function it_executes(
65
        CreateSepaMandate $request,
66
        MollieApiClient $mollieApiClient,
67
        ArrayObject $arrayObject,
68
        GatewayInterface $gateway,
69
        SessionInterface $session,
70
        CustomerEndpoint $customerEndpoint,
71
        Customer $customer,
72
        Mandate $mandate
73
    ): void {
74
        $this->setApi($mollieApiClient);
0 ignored issues
show
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

74
        $this->/** @scrutinizer ignore-call */ 
75
               setApi($mollieApiClient);
Loading history...
75
        $this->setGateway($gateway);
0 ignored issues
show
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

75
        $this->/** @scrutinizer ignore-call */ 
76
               setGateway($gateway);
Loading history...
76
        $mollieApiClient->customers = $customerEndpoint;
77
        $mandate->id = 'id_1';
78
        $customer->createMandate([
79
            'consumerAccount' => '57357086404',
80
            'consumerName' => 'Example',
81
            'method' => 'directdebit',
82
        ])->willReturn($mandate);
0 ignored issues
show
The method willReturn() does not exist on Mollie\Api\Resources\Mandate. ( Ignorable by Annotation )

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

82
        ])->/** @scrutinizer ignore-call */ willReturn($mandate);

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...
83
        $customerEndpoint->get('id_1')->willReturn($customer);
0 ignored issues
show
The method willReturn() does not exist on Mollie\Api\Resources\Customer. ( Ignorable by Annotation )

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

83
        $customerEndpoint->get('id_1')->/** @scrutinizer ignore-call */ willReturn($customer);

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...
84
        $session->get('mollie_direct_debit_data', null)->willReturn([
85
            'iban' => '57357086404',
86
            'consumerName' => 'Example',
87
        ]);
88
        $arrayObject->offsetGet('customer_mollie_id')->willReturn('id_1');
89
        $request->getModel()->willReturn($arrayObject);
90
91
        $arrayObject->offsetSet('mandate_mollie_id', 'id_1')->shouldBeCalled();
0 ignored issues
show
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...
92
93
        $this->execute($request);
0 ignored issues
show
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

93
        $this->/** @scrutinizer ignore-call */ 
94
               execute($request);
Loading history...
94
    }
95
96
    function it_supports_only_create_sepa_mandate_request_and_array_access(
97
        CreateSepaMandate $request,
98
        \ArrayAccess $arrayAccess
99
    ): void {
100
        $request->getModel()->willReturn($arrayAccess);
101
102
        $this->supports($request)->shouldReturn(true);
0 ignored issues
show
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

102
        $this->/** @scrutinizer ignore-call */ 
103
               supports($request)->shouldReturn(true);
Loading history...
103
    }
104
}
105