Issues (220)

Api/CreateRecurringSubscriptionActionSpec.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\CreateRecurringSubscriptionAction;
17
use BitBag\SyliusMolliePlugin\Client\MollieApiClient;
18
use BitBag\SyliusMolliePlugin\Entity\SubscriptionInterface;
19
use BitBag\SyliusMolliePlugin\Request\Api\CreateRecurringSubscription;
20
use Doctrine\ORM\EntityManagerInterface;
21
use Mollie\Api\Endpoints\CustomerEndpoint;
22
use Mollie\Api\Resources\Customer;
23
use Mollie\Api\Resources\Subscription;
24
use Payum\Core\Action\ActionInterface;
25
use Payum\Core\ApiAwareInterface;
26
use Payum\Core\Bridge\Spl\ArrayObject;
27
use Payum\Core\GatewayAwareInterface;
28
use Payum\Core\GatewayInterface;
29
use PhpSpec\ObjectBehavior;
30
use SM\Factory\FactoryInterface as SateMachineFactoryInterface;
31
use Sylius\Component\Core\Model\OrderInterface;
32
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
33
use Sylius\Component\Resource\Factory\FactoryInterface;
34
35
final class CreateRecurringSubscriptionActionSpec extends ObjectBehavior
36
{
37
    function let(
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...
38
        FactoryInterface $subscriptionFactory,
39
        EntityManagerInterface $subscriptionManager,
40
        SateMachineFactoryInterface $subscriptionSateMachineFactory,
41
        OrderRepositoryInterface $orderRepository
42
    ): void {
43
        $this->beConstructedWith(
44
            $subscriptionFactory,
45
            $subscriptionManager,
46
            $subscriptionSateMachineFactory,
47
            $orderRepository
48
        );
49
    }
50
51
    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...
52
    {
53
        $this->shouldHaveType(CreateRecurringSubscriptionAction::class);
54
    }
55
56
    function it_implements_action_interface(): void
57
    {
58
        $this->shouldHaveType(ActionInterface::class);
59
    }
60
61
    function it_implements_api_aware_interface(): void
62
    {
63
        $this->shouldHaveType(ApiAwareInterface::class);
64
    }
65
66
    function it_implements_gateway_aware_interface(): void
67
    {
68
        $this->shouldHaveType(GatewayAwareInterface::class);
69
    }
70
71
    function it_extends_base_api_aware(): void
72
    {
73
        $this->shouldHaveType(BaseApiAwareAction::class);
74
    }
75
76
    function it_executes(
77
        CreateRecurringSubscription $request,
78
        MollieApiClient $mollieApiClient,
79
        ArrayObject $arrayObject,
80
        CustomerEndpoint $customerEndpoint,
81
        Customer $customer,
82
        Subscription $subscriptionApi,
83
        FactoryInterface $subscriptionFactory,
84
        SubscriptionInterface $subscription,
85
        OrderInterface $order,
86
        OrderRepositoryInterface $orderRepository,
87
        GatewayInterface $gateway
88
    ): void {
89
        $this->setApi($mollieApiClient);
0 ignored issues
show
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

89
        $this->/** @scrutinizer ignore-call */ 
90
               setApi($mollieApiClient);
Loading history...
90
        $this->setGateway($gateway);
0 ignored issues
show
The method setGateway() 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
               setGateway($gateway);
Loading history...
91
        $mollieApiClient->customers = $customerEndpoint;
92
        $subscriptionApi->id = 'subscription_mollie_id';
93
        $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

93
        $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...
94
        $orderRepository->find(1)->willReturn($order);
95
        $subscriptionFactory->createNew()->willReturn($subscription);
96
        $arrayObject->offsetGet('customer_mollie_id')->willReturn('id_1');
97
        $arrayObject->offsetGet('interval')->willReturn('3 days');
98
        $arrayObject->offsetGet('description')->willReturn('');
99
        $arrayObject->offsetGet('webhookUrl')->willReturn('www.example.com/webhookUrl');
100
        $arrayObject->offsetGet('metadata')->willReturn(['order_id' => 1]);
101
        $arrayObject->offsetGet('amount')->willReturn(100);
102
        $customer->createSubscription([
103
            'amount' => 100,
104
            'interval' => '3 days',
105
            'description' => '',
106
            'method' => 'directdebit',
107
            'webhookUrl' => 'www.example.com/webhookUrl',
108
        ])->willReturn($subscriptionApi);
0 ignored issues
show
The method willReturn() does not exist on Mollie\Api\Resources\Subscription. ( Ignorable by Annotation )

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

108
        ])->/** @scrutinizer ignore-call */ willReturn($subscriptionApi);

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...
109
        $request->getModel()->willReturn($arrayObject);
110
111
        $arrayObject->offsetExists('subscription_id')->shouldBeCalled();
112
        $arrayObject->offsetSet('subscription_mollie_id', 'subscription_mollie_id')->shouldBeCalled();
0 ignored issues
show
Are you sure the usage of $arrayObject->offsetSet(...ubscription_mollie_id') 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...
113
114
        $this->execute($request);
0 ignored issues
show
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

114
        $this->/** @scrutinizer ignore-call */ 
115
               execute($request);
Loading history...
115
    }
116
117
    function it_supports_only_create_recurring_subscription_request_and_array_access(
118
        CreateRecurringSubscription $request,
119
        \ArrayAccess $arrayAccess
120
    ): void {
121
        $request->getModel()->willReturn($arrayAccess);
122
123
        $this->supports($request)->shouldReturn(true);
0 ignored issues
show
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

123
        $this->/** @scrutinizer ignore-call */ 
124
               supports($request)->shouldReturn(true);
Loading history...
124
    }
125
}
126