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\CaptureAction; |
||||||
16 | use BitBag\SyliusMolliePlugin\Client\MollieApiClient; |
||||||
17 | use Mollie\Api\Endpoints\PaymentEndpoint; |
||||||
18 | use Payum\Core\Action\ActionInterface; |
||||||
19 | use Payum\Core\ApiAwareInterface; |
||||||
20 | use Payum\Core\Bridge\Spl\ArrayObject; |
||||||
21 | use Payum\Core\GatewayAwareInterface; |
||||||
22 | use Payum\Core\GatewayInterface; |
||||||
23 | use Payum\Core\Payum; |
||||||
24 | use Payum\Core\Reply\HttpRedirect; |
||||||
25 | use Payum\Core\Request\Capture; |
||||||
26 | use Payum\Core\Security\GenericTokenFactory; |
||||||
27 | use Payum\Core\Security\GenericTokenFactoryAwareInterface; |
||||||
28 | use Payum\Core\Security\TokenInterface; |
||||||
29 | use PhpSpec\ObjectBehavior; |
||||||
30 | use Sylius\Component\Core\Model\PaymentInterface; |
||||||
31 | |||||||
32 | final class CaptureActionSpec extends ObjectBehavior |
||||||
33 | { |
||||||
34 | function it_is_initializable(): void |
||||||
0 ignored issues
–
show
|
|||||||
35 | { |
||||||
36 | $this->shouldHaveType(CaptureAction::class); |
||||||
37 | } |
||||||
38 | |||||||
39 | function it_implements_action_interface(): void |
||||||
40 | { |
||||||
41 | $this->shouldHaveType(ActionInterface::class); |
||||||
42 | } |
||||||
43 | |||||||
44 | function it_implements_generic_token_factory_aware(): void |
||||||
45 | { |
||||||
46 | $this->shouldHaveType(GenericTokenFactoryAwareInterface::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_executes( |
||||||
60 | Capture $request, |
||||||
61 | ArrayObject $arrayObject, |
||||||
62 | PaymentInterface $payment, |
||||||
63 | TokenInterface $token, |
||||||
64 | TokenInterface $notifyToken, |
||||||
65 | Payum $payum, |
||||||
66 | GenericTokenFactory $genericTokenFactory, |
||||||
67 | GatewayInterface $gateway, |
||||||
68 | MollieApiClient $mollieApiClient, |
||||||
69 | PaymentEndpoint $paymentEndpoint |
||||||
70 | ): void { |
||||||
71 | $this->setGateway($gateway); |
||||||
0 ignored issues
–
show
The method
setGateway() does not exist on spec\BitBag\SyliusMollie...ction\CaptureActionSpec . 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
![]() |
|||||||
72 | $mollieApiClient->isRecurringSubscription()->willReturn(false); |
||||||
73 | $this->setApi($mollieApiClient); |
||||||
0 ignored issues
–
show
The method
setApi() does not exist on spec\BitBag\SyliusMollie...ction\CaptureActionSpec . 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
![]() |
|||||||
74 | $notifyToken->getTargetUrl()->willReturn('url'); |
||||||
75 | $notifyToken->getHash()->willReturn('test'); |
||||||
76 | $token->getTargetUrl()->willReturn('url'); |
||||||
77 | $token->getAfterUrl()->willReturn('url'); |
||||||
78 | $token->getGatewayName()->willReturn('test'); |
||||||
79 | $token->getDetails()->willReturn([]); |
||||||
80 | $token->getHash()->willReturn('test'); |
||||||
81 | $genericTokenFactory->createNotifyToken('test', [])->willReturn($notifyToken); |
||||||
0 ignored issues
–
show
The method
willReturn() does not exist on Payum\Core\Security\TokenInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
82 | $genericTokenFactory->createRefundToken('test', [])->willReturn($notifyToken); |
||||||
83 | $this->setGenericTokenFactory($genericTokenFactory); |
||||||
0 ignored issues
–
show
The method
setGenericTokenFactory() does not exist on spec\BitBag\SyliusMollie...ction\CaptureActionSpec . 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
![]() |
|||||||
84 | $payum->getTokenFactory()->willReturn($genericTokenFactory); |
||||||
0 ignored issues
–
show
The method
willReturn() does not exist on Payum\Core\Security\GenericTokenFactoryInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
85 | $arrayObject->toUnsafeArray()->willReturn([]); |
||||||
86 | $request->getModel()->willReturn($arrayObject); |
||||||
87 | $request->getFirstModel()->willReturn($payment); |
||||||
88 | $request->getToken()->willReturn($token); |
||||||
89 | $payment = \Mockery::mock('payment'); |
||||||
90 | $payment->id = 1; |
||||||
0 ignored issues
–
show
|
|||||||
91 | $payment->shouldReceive('getCheckoutUrl')->andReturn('https://thisisnotanemptyurl.com'); |
||||||
92 | $paymentEndpoint->create([ |
||||||
93 | 'amount' => null, |
||||||
94 | 'description' => null, |
||||||
95 | 'redirectUrl' => 'url', |
||||||
96 | 'webhookUrl' => null, |
||||||
97 | 'metadata' => null, |
||||||
98 | ])->willReturn($payment); |
||||||
0 ignored issues
–
show
The method
willReturn() does not exist on Mollie\Api\Resources\Payment .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
99 | $mollieApiClient->payments = $paymentEndpoint; |
||||||
100 | |||||||
101 | $arrayObject->offsetGet('description')->shouldBeCalled(); |
||||||
102 | $arrayObject->offsetGet('webhookUrl')->shouldBeCalled(); |
||||||
103 | $arrayObject->offsetGet('amount')->shouldBeCalled(); |
||||||
104 | $arrayObject->offsetExists('subscription_mollie_id')->shouldBeCalled(); |
||||||
105 | $arrayObject->offsetExists('payment_mollie_id')->shouldBeCalled(); |
||||||
106 | $arrayObject->offsetExists('payment_mollie_id')->shouldBeCalled(); |
||||||
107 | $arrayObject->offsetGet('metadata')->shouldBeCalled(); |
||||||
108 | $arrayObject->offsetSet('metadata', ['refund_token' => 'test'])->shouldBeCalled(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$arrayObject->offsetSet(...fund_token' => 'test')) 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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
109 | $arrayObject->offsetSet('payment_mollie_id', 1)->shouldBeCalled(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$arrayObject->offsetSet('payment_mollie_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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
110 | $arrayObject->offsetSet('webhookUrl', 'url')->shouldBeCalled(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$arrayObject->offsetSet('webhookUrl', 'url') 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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
111 | |||||||
112 | $this |
||||||
113 | ->shouldThrow(HttpRedirect::class) |
||||||
114 | ->during('execute', [$request]) |
||||||
115 | ; |
||||||
116 | } |
||||||
117 | |||||||
118 | function it_supports_only_capture_request_and_array_access( |
||||||
119 | Capture $request, |
||||||
120 | \ArrayAccess $arrayAccess |
||||||
121 | ): void { |
||||||
122 | $request->getModel()->willReturn($arrayAccess); |
||||||
123 | |||||||
124 | $this->supports($request)->shouldReturn(true); |
||||||
0 ignored issues
–
show
The method
supports() does not exist on spec\BitBag\SyliusMollie...ction\CaptureActionSpec . 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
![]() |
|||||||
125 | } |
||||||
126 | } |
||||||
127 |
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.