RefundPaymentProcessorSpec::it_is_initializable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 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\SyliusQuadPayPlugin\PaymentProcessing;
14
15
use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClientInterface;
16
use BitBag\SyliusQuadPayPlugin\PaymentProcessing\PaymentProcessorInterface;
17
use BitBag\SyliusQuadPayPlugin\PaymentProcessing\RefundPaymentProcessor;
18
use BitBag\SyliusQuadPayPlugin\QuadPayGatewayFactory;
19
use Payum\Core\Model\GatewayConfigInterface;
20
use PhpSpec\ObjectBehavior;
21
use Prophecy\Argument;
22
use Sylius\Component\Core\Model\PaymentInterface;
23
use Sylius\Component\Core\Model\PaymentMethodInterface;
24
use Symfony\Component\HttpFoundation\Session\Session;
25
26
final class RefundPaymentProcessorSpec extends ObjectBehavior
27
{
28
    function let(Session $session, QuadPayApiClientInterface $quadPayApiClient): 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($session, $quadPayApiClient);
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(RefundPaymentProcessor::class);
36
    }
37
38
    function it_implements_payment_processor_interface(): void
39
    {
40
        $this->shouldHaveType(PaymentProcessorInterface::class);
41
    }
42
43
    function it_processes(
44
        PaymentInterface $payment,
45
        PaymentMethodInterface $paymentMethod,
46
        GatewayConfigInterface $gatewayConfig,
47
        QuadPayApiClientInterface $quadPayApiClient
48
    ): void {
49
        $gatewayConfig->getFactoryName()->willReturn(QuadPayGatewayFactory::FACTORY_NAME);
0 ignored issues
show
Deprecated Code introduced by
The function Payum\Core\Model\Gateway...rface::getFactoryName() has been deprecated: since 1.3.3 will be removed in 2.0. set factory option inside the config ( Ignorable by Annotation )

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

49
        /** @scrutinizer ignore-deprecated */ $gatewayConfig->getFactoryName()->willReturn(QuadPayGatewayFactory::FACTORY_NAME);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
50
        $gatewayConfig->getConfig()->willReturn([
51
            'clientId' => 'test',
52
            'clientSecret' => 'test',
53
            'apiEndpoint' => 'https://api-ci.quadpay.com/',
54
            'authTokenEndpoint' => 'https://api-ci.quadpay.com/',
55
            'apiAudience' => 'https://api-ci.quadpay.com/',
56
        ]);
57
        $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Payum\Core\Model\GatewayConfigInterface. ( Ignorable by Annotation )

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

57
        $paymentMethod->getGatewayConfig()->/** @scrutinizer ignore-call */ willReturn($gatewayConfig);

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...
58
        $payment->getMethod()->willReturn($paymentMethod);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Payment...\PaymentMethodInterface. ( Ignorable by Annotation )

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

58
        $payment->getMethod()->/** @scrutinizer ignore-call */ willReturn($paymentMethod);

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...
59
        $payment->getAmount()->willReturn(222222);
60
        $payment->getDetails()->willReturn([
61
            'orderToken' => 'test',
62
        ]);
63
        /** @var string|array $argumentAny */
64
        $argumentAny = Argument::any();
65
        $quadPayApiClient->setConfig(
66
            'test',
67
            'test',
68
            'https://api-ci.quadpay.com/',
69
            'https://api-ci.quadpay.com/',
70
            'https://api-ci.quadpay.com/'
71
        );
72
        $quadPayApiClient->refund(2222.22, $argumentAny, 'test', null)->willReturn(['refundId' => 'test']);
0 ignored issues
show
Bug introduced by
It seems like $argumentAny can also be of type array; however, parameter $merchantRefundReference of BitBag\SyliusQuadPayPlug...ientInterface::refund() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

72
        $quadPayApiClient->refund(2222.22, /** @scrutinizer ignore-type */ $argumentAny, 'test', null)->willReturn(['refundId' => 'test']);
Loading history...
73
74
        $payment->setDetails($argumentAny)->shouldBeCalled();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $payment->setDetails($argumentAny) targeting Sylius\Component\Payment...Interface::setDetails() 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...
Bug introduced by
It seems like $argumentAny can also be of type string; however, parameter $details of Sylius\Component\Payment...Interface::setDetails() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

74
        $payment->setDetails(/** @scrutinizer ignore-type */ $argumentAny)->shouldBeCalled();
Loading history...
75
76
        $this->process($payment);
0 ignored issues
show
Bug introduced by
The method process() does not exist on spec\BitBag\SyliusQuadPa...undPaymentProcessorSpec. 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

76
        $this->/** @scrutinizer ignore-call */ 
77
               process($payment);
Loading history...
77
    }
78
}
79