it_provide_product_variants_deposit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 4
dl 0
loc 22
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Gewebe\SyliusProductDepositPlugin\Provider;
6
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariantInterface;
9
use Gewebe\SyliusProductDepositPlugin\Provider\ProductVariantsDepositsProvider;
10
use Gewebe\SyliusProductDepositPlugin\Provider\ProductVariantsDepositsProviderInterface;
11
use PhpSpec\ObjectBehavior;
12
use Sylius\Component\Core\Model\ChannelInterface;
13
use Sylius\Component\Core\Model\ProductInterface;
14
use Sylius\Component\Product\Model\ProductOptionValueInterface;
15
16
final class ProductVariantsDepositsProviderSpec extends ObjectBehavior
17
{
18
    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...
19
    {
20
        $this->shouldHaveType(ProductVariantsDepositsProvider::class);
21
    }
22
23
    function it_implements_product_variants_deposits_provider(): void
24
    {
25
        $this->shouldImplement(ProductVariantsDepositsProviderInterface::class);
26
    }
27
28
    function it_provide_product_variants_deposit(
29
        ProductInterface $product,
30
        ProductVariantInterface $productVariant,
31
        ProductOptionValueInterface $productOptionValue,
32
        ChannelInterface $channel
33
    ): void {
34
        $productVariant->getDepositPriceByChannel($channel)->willReturn(50);
35
36
        $productOptionValue->getCode()->willReturn('1 liter');
37
        $productOptionValue->getOptionCode()->willReturn('1_liter');
38
        $productOptionValues = new ArrayCollection([$productOptionValue->getWrappedObject()]);
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not exist on Sylius\Component\Product...uctOptionValueInterface. ( Ignorable by Annotation )

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

38
        $productOptionValues = new ArrayCollection([$productOptionValue->/** @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...
39
        $productVariant->getOptionValues()->willReturn($productOptionValues);
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

39
        $productVariant->getOptionValues()->/** @scrutinizer ignore-call */ willReturn($productOptionValues);

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...
40
41
        $variants = new ArrayCollection([$productVariant->getWrappedObject()]);
0 ignored issues
show
Bug introduced by
The method getWrappedObject() does not exist on Gewebe\SyliusProductDepo...ProductVariantInterface. ( Ignorable by Annotation )

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

41
        $variants = new ArrayCollection([$productVariant->/** @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...
42
        $product->getVariants()->willReturn($variants);
43
44
        $variantsDeposit = $this->provideVariantsDeposits($product, $channel);
0 ignored issues
show
Bug introduced by
The method provideVariantsDeposits() does not exist on spec\Gewebe\SyliusProduc...ntsDepositsProviderSpec. 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

44
        /** @scrutinizer ignore-call */ 
45
        $variantsDeposit = $this->provideVariantsDeposits($product, $channel);
Loading history...
45
        $variantsDeposit->shouldHaveCount(1);
46
        $variantsDeposit->shouldReturn([
47
            0 => [
48
                '1_liter' => '1 liter',
49
                'value' => 50
50
            ]
51
        ]);
52
    }
53
}
54