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\Resolver; |
||||||
14 | |||||||
15 | use BitBag\SyliusQuadPayPlugin\Client\QuadPayApiClientInterface; |
||||||
16 | use BitBag\SyliusQuadPayPlugin\QuadPayGatewayFactory; |
||||||
17 | use BitBag\SyliusQuadPayPlugin\Resolver\PaymentStateResolver; |
||||||
18 | use BitBag\SyliusQuadPayPlugin\Resolver\PaymentStateResolverInterface; |
||||||
19 | use Doctrine\ORM\EntityManagerInterface; |
||||||
20 | use Payum\Core\Model\GatewayConfigInterface; |
||||||
21 | use PhpSpec\ObjectBehavior; |
||||||
22 | use SM\Factory\FactoryInterface; |
||||||
23 | use SM\StateMachine\StateMachineInterface; |
||||||
24 | use Sylius\Component\Core\Model\PaymentInterface; |
||||||
25 | use Sylius\Component\Core\Model\PaymentMethodInterface; |
||||||
26 | use Sylius\Component\Payment\PaymentTransitions; |
||||||
27 | |||||||
28 | final class PaymentStateResolverSpec extends ObjectBehavior |
||||||
29 | { |
||||||
30 | function let( |
||||||
0 ignored issues
–
show
|
|||||||
31 | FactoryInterface $stateMachineFactory, |
||||||
32 | QuadPayApiClientInterface $quadPayApiClient, |
||||||
33 | EntityManagerInterface $paymentEntityManager |
||||||
34 | ): void { |
||||||
35 | $this->beConstructedWith($stateMachineFactory, $quadPayApiClient, $paymentEntityManager); |
||||||
36 | } |
||||||
37 | |||||||
38 | function it_is_initializable(): void |
||||||
0 ignored issues
–
show
|
|||||||
39 | { |
||||||
40 | $this->shouldHaveType(PaymentStateResolver::class); |
||||||
41 | } |
||||||
42 | |||||||
43 | function it_implements_payment_state_resolver_interface(): void |
||||||
44 | { |
||||||
45 | $this->shouldHaveType(PaymentStateResolverInterface::class); |
||||||
46 | } |
||||||
47 | |||||||
48 | function it_resolves( |
||||||
49 | PaymentInterface $payment, |
||||||
50 | PaymentMethodInterface $paymentMethod, |
||||||
51 | GatewayConfigInterface $gatewayConfig, |
||||||
52 | QuadPayApiClientInterface $quadPayApiClient, |
||||||
53 | FactoryInterface $stateMachineFactory, |
||||||
54 | StateMachineInterface $stateMachine |
||||||
55 | ): void { |
||||||
56 | $gatewayConfig->getFactoryName()->willReturn(QuadPayGatewayFactory::FACTORY_NAME); |
||||||
0 ignored issues
–
show
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
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. ![]() |
|||||||
57 | $gatewayConfig->getConfig()->willReturn([ |
||||||
58 | 'clientId' => 'test', |
||||||
59 | 'clientSecret' => 'test', |
||||||
60 | 'apiEndpoint' => 'https://api-ci.quadpay.com/', |
||||||
61 | 'authTokenEndpoint' => 'https://api-ci.quadpay.com/', |
||||||
62 | 'apiAudience' => 'https://api-ci.quadpay.com/', |
||||||
63 | ]); |
||||||
64 | $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); |
||||||
0 ignored issues
–
show
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
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. ![]() |
|||||||
65 | $payment->getMethod()->willReturn($paymentMethod); |
||||||
0 ignored issues
–
show
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
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. ![]() |
|||||||
66 | $payment->getAmount()->willReturn(222222); |
||||||
67 | $payment->getDetails()->willReturn([ |
||||||
68 | 'orderToken' => 'test', |
||||||
69 | ]); |
||||||
70 | $quadPayApiClient->setConfig( |
||||||
71 | 'test', |
||||||
72 | 'test', |
||||||
73 | 'https://api-ci.quadpay.com/', |
||||||
74 | 'https://api-ci.quadpay.com/', |
||||||
75 | 'https://api-ci.quadpay.com/' |
||||||
76 | ); |
||||||
77 | $quadPayApiClient->getOrderByToken('test')->willReturn(['orderStatus' => QuadPayApiClientInterface::STATUS_APPROVED]); |
||||||
78 | $stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->willReturn($stateMachine); |
||||||
0 ignored issues
–
show
The method
willReturn() does not exist on SM\StateMachine\StateMachineInterface .
(
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. ![]() |
|||||||
79 | $stateMachine->can(PaymentTransitions::TRANSITION_COMPLETE)->willReturn(true); |
||||||
80 | |||||||
81 | $payment->setDetails(['orderToken' => 'test', 'orderStatus' => 'approved'])->shouldBeCalled(); |
||||||
0 ignored issues
–
show
Are you sure the usage of
$payment->setDetails(arr...Status' => 'approved')) 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 The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||
82 | $stateMachine->apply(PaymentTransitions::TRANSITION_COMPLETE)->shouldBeCalled(); |
||||||
83 | |||||||
84 | $this->resolve($payment); |
||||||
0 ignored issues
–
show
The method
resolve() does not exist on spec\BitBag\SyliusQuadPa...aymentStateResolverSpec . 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
![]() |
|||||||
85 | } |
||||||
86 | } |
||||||
87 |
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.