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 Mollie\Api\Endpoints\CustomerEndpoint; |
21
|
|
|
use Mollie\Api\Resources\Customer; |
22
|
|
|
use Payum\Core\Action\ActionInterface; |
23
|
|
|
use Payum\Core\ApiAwareInterface; |
24
|
|
|
use PhpSpec\ObjectBehavior; |
25
|
|
|
|
26
|
|
|
final class CancelRecurringSubscriptionActionSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function it_is_initializable(): void |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
$this->shouldHaveType(CancelRecurringSubscriptionAction::class); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_implements_action_interface(): void |
34
|
|
|
{ |
35
|
|
|
$this->shouldHaveType(ActionInterface::class); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_implements_api_aware_interface(): void |
39
|
|
|
{ |
40
|
|
|
$this->shouldHaveType(ApiAwareInterface::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function it_extends_base_api_aware(): void |
44
|
|
|
{ |
45
|
|
|
$this->shouldHaveType(BaseApiAwareAction::class); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
function it_executes( |
49
|
|
|
CancelRecurringSubscription $request, |
50
|
|
|
MollieApiClient $mollieApiClient, |
51
|
|
|
SubscriptionInterface $subscription, |
52
|
|
|
CustomerEndpoint $customerEndpoint, |
53
|
|
|
Customer $customer |
54
|
|
|
): void { |
55
|
|
|
$mollieApiClient->customers = $customerEndpoint; |
56
|
|
|
$this->setApi($mollieApiClient); |
|
|
|
|
57
|
|
|
$customerEndpoint->get('id_1')->willReturn($customer); |
|
|
|
|
58
|
|
|
$subscription->getSubscriptionId()->willReturn('id_1'); |
59
|
|
|
$subscription->getCustomerId()->willReturn('id_1'); |
60
|
|
|
$request->getModel()->willReturn($subscription); |
61
|
|
|
|
62
|
|
|
$customer->cancelSubscription('id_1')->shouldBeCalled(); |
|
|
|
|
63
|
|
|
|
64
|
|
|
$this->execute($request); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function it_supports_cancel_recurring_subscription_request_and_subscription_model( |
68
|
|
|
CancelRecurringSubscription $request, |
69
|
|
|
SubscriptionInterface $subscription |
70
|
|
|
): void { |
71
|
|
|
$request->getModel()->willReturn($subscription); |
72
|
|
|
|
73
|
|
|
$this->supports($request)->shouldReturn(true); |
|
|
|
|
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.