OrderDepositProcessorSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 11 1
A it_process_order_deposit() 0 35 1
A it_implements_order_processor_interface() 0 3 1
A it_is_initializable() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Gewebe\SyliusProductDepositPlugin\OrderProcessing;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Gewebe\SyliusProductDepositPlugin\Entity\AdjustmentInterface;
9
use Gewebe\SyliusProductDepositPlugin\Entity\ChannelDepositInterface;
10
use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariantInterface;
11
use Gewebe\SyliusProductDepositPlugin\OrderProcessing\OrderDepositProcessor;
12
use PhpSpec\ObjectBehavior;
13
use Sylius\Component\Addressing\Matcher\ZoneMatcherInterface;
14
use Sylius\Component\Addressing\Model\ZoneInterface;
15
use Sylius\Component\Core\Model\AddressInterface;
16
use Sylius\Component\Core\Model\ChannelInterface;
17
use Sylius\Component\Core\Model\OrderInterface;
18
use Sylius\Component\Core\Model\OrderItemInterface;
19
use Sylius\Component\Core\Model\OrderItemUnitInterface;
20
use Sylius\Component\Core\Provider\ZoneProviderInterface;
21
use Sylius\Component\Core\Taxation\Applicator\OrderTaxesApplicatorInterface;
22
use Sylius\Component\Order\Factory\AdjustmentFactoryInterface;
23
use Sylius\Component\Order\Processor\OrderProcessorInterface;
24
25
final class OrderDepositProcessorSpec extends ObjectBehavior
26
{
27
    function let(
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...
28
        AdjustmentFactoryInterface $adjustmentFactory,
29
        OrderTaxesApplicatorInterface $orderTaxesApplicator,
30
        ZoneMatcherInterface $zoneMatcher,
31
        ZoneProviderInterface $defaultTaxZoneProvider
32
    ): void {
33
        $this->beConstructedWith(
34
            $adjustmentFactory,
35
            $orderTaxesApplicator,
36
            $zoneMatcher,
37
            $defaultTaxZoneProvider
38
        );
39
    }
40
41
    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...
42
    {
43
        $this->shouldHaveType(OrderDepositProcessor::class);
44
    }
45
46
    function it_implements_order_processor_interface(): void
47
    {
48
        $this->shouldImplement(OrderProcessorInterface::class);
49
    }
50
51
    function it_process_order_deposit(
52
        AddressInterface $address,
53
        AdjustmentInterface $adjustment,
54
        AdjustmentFactoryInterface $adjustmentFactory,
55
        ChannelInterface $channel,
56
        OrderInterface $order,
57
        OrderItemInterface $orderItem,
58
        OrderItemUnitInterface $orderItemUnit,
59
        OrderTaxesApplicatorInterface $orderTaxesApplicator,
60
        ProductVariantInterface $productVariant,
61
        ZoneProviderInterface $defaultTaxZoneProvider,
62
        ZoneMatcherInterface $zoneMatcher,
63
        ZoneInterface $zone
64
    ): void {
65
        $order->getChannel()->willReturn($channel);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Channel\Model\ChannelInterface. ( Ignorable by Annotation )

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

65
        $order->getChannel()->/** @scrutinizer ignore-call */ willReturn($channel);

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...
66
        $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()]));
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

66
        $order->getItems()->/** @scrutinizer ignore-call */ willReturn(new ArrayCollection([$orderItem->getWrappedObject()]));

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...
Bug introduced by
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 ignore-call  annotation

66
        $order->getItems()->willReturn(new ArrayCollection([$orderItem->/** @scrutinizer ignore-call */ getWrappedObject()]));

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...
67
        $order->getShippingAddress()->willReturn($address);
0 ignored issues
show
Bug introduced by
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 ignore-call  annotation

67
        $order->getShippingAddress()->/** @scrutinizer ignore-call */ willReturn($address);

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...
68
69
        $orderItem->getVariant()->willReturn($productVariant);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Core\Mo...ProductVariantInterface. ( Ignorable by Annotation )

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

69
        $orderItem->getVariant()->/** @scrutinizer ignore-call */ willReturn($productVariant);

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...
70
        $orderItem->getUnits()->willReturn(new ArrayCollection([$orderItemUnit->getWrappedObject()]));
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not exist on Sylius\Component\Core\Model\OrderItemUnitInterface. ( Ignorable by Annotation )

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

70
        $orderItem->getUnits()->willReturn(new ArrayCollection([$orderItemUnit->/** @scrutinizer ignore-call */ getWrappedObject()]));

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...
71
72
        $productVariant->getDepositPriceByChannel($channel)->willReturn(50);
73
74
        $orderItemUnit->addAdjustment($adjustment)->shouldBeCalled();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $orderItemUnit->addAdjustment($adjustment) targeting Sylius\Component\Order\M...erface::addAdjustment() 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...
75
76
        $adjustmentFactory->createWithData(
77
            AdjustmentInterface::DEPOSIT_ADJUSTMENT,
78
            'Deposit',
79
            50
80
        )->willReturn($adjustment);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Order\Model\AdjustmentInterface. ( Ignorable by Annotation )

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

80
        )->/** @scrutinizer ignore-call */ willReturn($adjustment);

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...
81
82
        $defaultTaxZoneProvider->getZone($order)->willReturn($zone);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Addressing\Model\ZoneInterface. ( Ignorable by Annotation )

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

82
        $defaultTaxZoneProvider->getZone($order)->/** @scrutinizer ignore-call */ willReturn($zone);

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
        $this->beConstructedWith($adjustmentFactory, $orderTaxesApplicator, $zoneMatcher, $defaultTaxZoneProvider);
84
85
        $this->process($order);
0 ignored issues
show
Bug introduced by
The method process() does not exist on spec\Gewebe\SyliusProduc...derDepositProcessorSpec. 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

85
        $this->/** @scrutinizer ignore-call */ 
86
               process($order);
Loading history...
86
    }
87
}
88