BitBagCommerce /
SyliusQuadPayPlugin
| 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\Action; |
||||||
| 14 | |||||||
| 15 | use BitBag\SyliusQuadPayPlugin\Action\ConvertPaymentAction; |
||||||
| 16 | use Doctrine\Common\Collections\ArrayCollection; |
||||||
| 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\AddressInterface; |
||||||
| 23 | use Sylius\Component\Core\Model\CustomerInterface; |
||||||
| 24 | use Sylius\Component\Core\Model\OrderInterface; |
||||||
| 25 | use Sylius\Component\Core\Model\OrderItemInterface; |
||||||
| 26 | use Sylius\Component\Core\Model\PaymentInterface; |
||||||
| 27 | use Sylius\Component\Core\Model\ProductInterface; |
||||||
| 28 | |||||||
| 29 | final class ConvertPaymentActionSpec extends ObjectBehavior |
||||||
| 30 | { |
||||||
| 31 | function let(PaymentDescriptionProviderInterface $paymentDescriptionProvider): void |
||||||
|
0 ignored issues
–
show
|
|||||||
| 32 | { |
||||||
| 33 | $this->beConstructedWith($paymentDescriptionProvider); |
||||||
| 34 | } |
||||||
| 35 | |||||||
| 36 | function it_is_initializable(): void |
||||||
|
0 ignored issues
–
show
|
|||||||
| 37 | { |
||||||
| 38 | $this->shouldHaveType(ConvertPaymentAction::class); |
||||||
| 39 | } |
||||||
| 40 | |||||||
| 41 | function it_implements_action_interface(): void |
||||||
| 42 | { |
||||||
| 43 | $this->shouldHaveType(ActionInterface::class); |
||||||
| 44 | } |
||||||
| 45 | |||||||
| 46 | function it_executes( |
||||||
| 47 | Convert $request, |
||||||
| 48 | PaymentInterface $payment, |
||||||
| 49 | OrderInterface $order, |
||||||
| 50 | CustomerInterface $customer, |
||||||
| 51 | GatewayInterface $gateway, |
||||||
| 52 | PaymentDescriptionProviderInterface $paymentDescriptionProvider, |
||||||
| 53 | AddressInterface $address, |
||||||
| 54 | OrderItemInterface $orderItem, |
||||||
| 55 | ProductInterface $product |
||||||
| 56 | ): void { |
||||||
| 57 | $this->setGateway($gateway); |
||||||
|
0 ignored issues
–
show
The method
setGateway() does not exist on spec\BitBag\SyliusQuadPa...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...
|
|||||||
| 58 | $customer->getFullName()->willReturn('Jan Kowalski'); |
||||||
| 59 | $customer->getEmail()->willReturn('[email protected]'); |
||||||
| 60 | $customer->getId()->willReturn(1); |
||||||
| 61 | $address->getPhoneNumber()->willReturn(353464674); |
||||||
| 62 | $address->getCity()->willReturn('test'); |
||||||
| 63 | $address->getStreet()->willReturn('test'); |
||||||
| 64 | $address->getPostcode()->willReturn('353664'); |
||||||
| 65 | $address->getLastName()->willReturn('test'); |
||||||
| 66 | $address->getFirstName()->willReturn('test'); |
||||||
| 67 | $address->getProvinceCode()->willReturn(null); |
||||||
| 68 | $product->getShortDescription()->willReturn('description'); |
||||||
| 69 | $product->getName()->willReturn('name'); |
||||||
| 70 | $product->getCode()->willReturn('code'); |
||||||
| 71 | $orderItem->getProduct()->willReturn($product); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on Sylius\Component\Core\Model\ProductInterface.
(
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...
|
|||||||
| 72 | $orderItem->getQuantity()->willReturn(1); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on integer.
(
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...
|
|||||||
| 73 | $orderItem->getUnitPrice()->willReturn(20); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on integer.
(
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...
|
|||||||
| 74 | $order->getId()->willReturn(1); |
||||||
| 75 | $order->getLocaleCode()->willReturn('pl_PL'); |
||||||
| 76 | $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...
|
|||||||
| 77 | $order->getShippingAddress()->willReturn($address); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on Sylius\Component\Core\Model\AddressInterface.
(
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...
|
|||||||
| 78 | $order->getBillingAddress()->willReturn($address); |
||||||
| 79 | $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); |
||||||
|
0 ignored issues
–
show
The method
getWrappedObject() does not exist on Sylius\Component\Core\Model\OrderItemInterface.
(
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...
The method
willReturn() does not exist on Doctrine\Common\Collections\Collection.
(
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...
|
|||||||
| 80 | $order->getNumber()->willReturn('0000001'); |
||||||
| 81 | $order->getTaxTotal()->willReturn(100); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on integer.
(
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...
|
|||||||
| 82 | $order->getShippingTotal()->willReturn(100); |
||||||
|
0 ignored issues
–
show
The method
willReturn() does not exist on integer.
(
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...
|
|||||||
| 83 | $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...
|
|||||||
| 84 | $payment->getAmount()->willReturn(445535); |
||||||
| 85 | $payment->getCurrencyCode()->willReturn('EUR'); |
||||||
| 86 | $paymentDescriptionProvider->getPaymentDescription($payment)->willReturn('description'); |
||||||
| 87 | $request->getSource()->willReturn($payment); |
||||||
| 88 | $request->getTo()->willReturn('array'); |
||||||
| 89 | |||||||
| 90 | $request->setResult([ |
||||||
|
0 ignored issues
–
show
Are you sure the usage of
$request->setResult(arra...ngAmount' => '100.00')) 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...
|
|||||||
| 91 | 'amount' => '445535.00', |
||||||
| 92 | 'consumer' => [ |
||||||
| 93 | 'phoneNumber' => '353464674', |
||||||
| 94 | 'givenNames' => 'test', |
||||||
| 95 | 'surname' => 'test', |
||||||
| 96 | 'email' => '[email protected]', |
||||||
| 97 | ], |
||||||
| 98 | 'billing' => [ |
||||||
| 99 | 'addressLine1' => 'test', |
||||||
| 100 | 'addressLine2' => '', |
||||||
| 101 | 'city' => 'test', |
||||||
| 102 | 'postcode' => '353664', |
||||||
| 103 | 'state' => '', |
||||||
| 104 | ], |
||||||
| 105 | 'shipping' => [ |
||||||
| 106 | 'addressLine1' => 'test', |
||||||
| 107 | 'addressLine2' => '', |
||||||
| 108 | 'city' => 'test', |
||||||
| 109 | 'postcode' => '353664', |
||||||
| 110 | 'state' => '', |
||||||
| 111 | ], |
||||||
| 112 | 'description' => 'description', |
||||||
| 113 | 'items' => [ |
||||||
| 114 | [ |
||||||
| 115 | 'description' => 'description', |
||||||
| 116 | 'name' => 'name', |
||||||
| 117 | 'sku' => 'code', |
||||||
| 118 | 'quantity' => 1, |
||||||
| 119 | 'price' => '20.00', |
||||||
| 120 | ], |
||||||
| 121 | ], |
||||||
| 122 | 'merchantReference' => '0000001', |
||||||
| 123 | 'taxAmount' => '100.00', |
||||||
| 124 | 'shippingAmount' => '100.00', |
||||||
| 125 | ] |
||||||
| 126 | )->shouldBeCalled(); |
||||||
| 127 | |||||||
| 128 | $this->execute($request); |
||||||
|
0 ignored issues
–
show
The method
execute() does not exist on spec\BitBag\SyliusQuadPa...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...
|
|||||||
| 129 | } |
||||||
| 130 | |||||||
| 131 | function it_supports_only_convert_request_payment_source_and_array_to( |
||||||
| 132 | Convert $request, |
||||||
| 133 | PaymentInterface $payment |
||||||
| 134 | ): void { |
||||||
| 135 | $request->getSource()->willReturn($payment); |
||||||
| 136 | $request->getTo()->willReturn('array'); |
||||||
| 137 | |||||||
| 138 | $this->supports($request)->shouldReturn(true); |
||||||
|
0 ignored issues
–
show
The method
supports() does not exist on spec\BitBag\SyliusQuadPa...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...
|
|||||||
| 139 | } |
||||||
| 140 | } |
||||||
| 141 |
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.