BitBagCommerce /
SyliusMolliePlugin
| 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\ConvertPaymentAction; |
||||||
| 16 | use BitBag\SyliusMolliePlugin\Client\MollieApiClient; |
||||||
| 17 | use Payum\Core\Action\ActionInterface; |
||||||
| 18 | use Payum\Core\GatewayInterface; |
||||||
| 19 | use Payum\Core\Request\Convert; |
||||||
| 20 | use PhpSpec\ObjectBehavior; |
||||||
| 21 | use Sylius\Bundle\PayumBundle\Provider\PaymentDescriptionProviderInterface; |
||||||
| 22 | use Sylius\Component\Core\Model\CustomerInterface; |
||||||
| 23 | use Sylius\Component\Core\Model\OrderInterface; |
||||||
| 24 | use Sylius\Component\Core\Model\PaymentInterface; |
||||||
| 25 | |||||||
| 26 | final class ConvertPaymentActionSpec extends ObjectBehavior |
||||||
| 27 | { |
||||||
| 28 | function let(PaymentDescriptionProviderInterface $paymentDescriptionProvider): void |
||||||
|
0 ignored issues
–
show
|
|||||||
| 29 | { |
||||||
| 30 | $this->beConstructedWith($paymentDescriptionProvider); |
||||||
| 31 | } |
||||||
| 32 | |||||||
| 33 | function it_is_initializable(): void |
||||||
|
0 ignored issues
–
show
|
|||||||
| 34 | { |
||||||
| 35 | $this->shouldHaveType(ConvertPaymentAction::class); |
||||||
| 36 | } |
||||||
| 37 | |||||||
| 38 | function it_implements_action_interface(): void |
||||||
| 39 | { |
||||||
| 40 | $this->shouldHaveType(ActionInterface::class); |
||||||
| 41 | } |
||||||
| 42 | |||||||
| 43 | function it_executes( |
||||||
| 44 | Convert $request, |
||||||
| 45 | PaymentInterface $payment, |
||||||
| 46 | OrderInterface $order, |
||||||
| 47 | CustomerInterface $customer, |
||||||
| 48 | GatewayInterface $gateway, |
||||||
| 49 | MollieApiClient $mollieApiClient, |
||||||
| 50 | PaymentDescriptionProviderInterface $paymentDescriptionProvider |
||||||
| 51 | ): void { |
||||||
| 52 | $mollieApiClient->isRecurringSubscription()->willReturn(false); |
||||||
| 53 | $this->setApi($mollieApiClient); |
||||||
|
0 ignored issues
–
show
The method
setApi() does not exist on spec\BitBag\SyliusMollie...onvertPaymentActionSpec. 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
Loading history...
|
|||||||
| 54 | $this->setGateway($gateway); |
||||||
|
0 ignored issues
–
show
The method
setGateway() does not exist on spec\BitBag\SyliusMollie...onvertPaymentActionSpec. 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
Loading history...
|
|||||||
| 55 | $customer->getFullName()->willReturn('Jan Kowalski'); |
||||||
| 56 | $customer->getEmail()->willReturn('[email protected]'); |
||||||
| 57 | $customer->getId()->willReturn(1); |
||||||
| 58 | $order->getId()->willReturn(1); |
||||||
| 59 | $order->getLocaleCode()->willReturn('pl_PL'); |
||||||
| 60 | $order->getCustomer()->willReturn($customer); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on Sylius\Component\Customer\Model\CustomerInterface.
(
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. Loading history...
|
|||||||
| 61 | $payment->getOrder()->willReturn($order); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on Sylius\Component\Order\Model\OrderInterface.
(
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. Loading history...
|
|||||||
| 62 | $payment->getAmount()->willReturn(445535); |
||||||
| 63 | $payment->getCurrencyCode()->willReturn('EUR'); |
||||||
| 64 | $paymentDescriptionProvider->getPaymentDescription($payment)->willReturn('description'); |
||||||
| 65 | $request->getSource()->willReturn($payment); |
||||||
| 66 | $request->getTo()->willReturn('array'); |
||||||
| 67 | |||||||
| 68 | $request->setResult([ |
||||||
|
0 ignored issues
–
show
Are you sure the usage of
$request->setResult(arra...=> '[email protected]')) targeting Payum\Core\Request\Convert::setResult() 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. Loading history...
|
|||||||
| 69 | 'amount' => [ |
||||||
| 70 | 'value' => '445535', |
||||||
| 71 | 'currency' => 'EUR', |
||||||
| 72 | ], |
||||||
| 73 | 'description' => 'description', |
||||||
| 74 | 'locale' => 'en_US', |
||||||
| 75 | 'metadata' => [ |
||||||
| 76 | 'order_id' => 1, |
||||||
| 77 | 'customer_id' => 1, |
||||||
| 78 | ], |
||||||
| 79 | 'full_name' => 'Jan Kowalski', |
||||||
| 80 | 'email' => '[email protected]', |
||||||
| 81 | ])->shouldBeCalled(); |
||||||
| 82 | |||||||
| 83 | $this->execute($request); |
||||||
|
0 ignored issues
–
show
The method
execute() does not exist on spec\BitBag\SyliusMollie...onvertPaymentActionSpec. 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
Loading history...
|
|||||||
| 84 | } |
||||||
| 85 | |||||||
| 86 | function it_supports_only_convert_request_payment_source_and_array_to( |
||||||
| 87 | Convert $request, |
||||||
| 88 | PaymentInterface $payment |
||||||
| 89 | ): void { |
||||||
| 90 | $request->getSource()->willReturn($payment); |
||||||
| 91 | $request->getTo()->willReturn('array'); |
||||||
| 92 | |||||||
| 93 | $this->supports($request)->shouldReturn(true); |
||||||
|
0 ignored issues
–
show
The method
supports() does not exist on spec\BitBag\SyliusMollie...onvertPaymentActionSpec. 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
Loading history...
|
|||||||
| 94 | } |
||||||
| 95 | } |
||||||
| 96 |
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.