Completed
Pull Request — master (#54)
by Konrad
04:41
created

ChannelPricingTransformerSpec   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 6 1
A it_transforms_product_channel_prices_into_formatted_price() 0 20 1
A it_is_a_transformer() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\BitBag\SyliusElasticsearchPlugin\Transformer\Product;
6
7
use BitBag\SyliusElasticsearchPlugin\Transformer\Product\TransformerInterface;
8
use PhpSpec\ObjectBehavior;
9
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
10
use Sylius\Component\Channel\Context\ChannelContextInterface;
11
use Sylius\Component\Core\Model\ChannelInterface;
12
use Sylius\Component\Core\Model\ChannelPricingInterface;
13
use Sylius\Component\Core\Model\ProductInterface;
14
use Sylius\Component\Core\Model\ProductVariantInterface;
15
use Sylius\Component\Currency\Model\CurrencyInterface;
16
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
17
18
final class ChannelPricingTransformerSpec extends ObjectBehavior
19
{
20
    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...
21
        ChannelContextInterface $channelContext,
22
        ProductVariantResolverInterface $productVariantResolver,
23
        MoneyFormatterInterface $moneyFormatter
24
    ): void {
25
        $this->beConstructedWith($channelContext, $productVariantResolver, $moneyFormatter);
26
    }
27
28
    function it_is_a_transformer(): 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...
29
    {
30
        $this->shouldImplement(TransformerInterface::class);
31
    }
32
33
    function it_transforms_product_channel_prices_into_formatted_price(
34
        ChannelContextInterface $channelContext,
35
        ProductVariantResolverInterface $productVariantResolver,
36
        MoneyFormatterInterface $moneyFormatter,
37
        CurrencyInterface $currency,
38
        ChannelInterface $channel,
39
        ProductVariantInterface $productVariant,
40
        ProductInterface $product,
41
        ChannelPricingInterface $channelPricing
42
    ): void {
43
        $currency->getCode()->willReturn('USD');
44
        $channel->getBaseCurrency()->willReturn($currency);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Currency\Model\CurrencyInterface. ( Ignorable by Annotation )

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

44
        $channel->getBaseCurrency()->/** @scrutinizer ignore-call */ willReturn($currency);

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...
45
        $channelContext->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

45
        $channelContext->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...
46
        $productVariantResolver->getVariant($product)->willReturn($productVariant);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Product...ProductVariantInterface. ( Ignorable by Annotation )

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

46
        $productVariantResolver->getVariant($product)->/** @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...
47
        $channelPricing->getPrice()->willReturn(10);
48
        $productVariant->getChannelPricingForChannel($channel)->willReturn($channelPricing);
0 ignored issues
show
Bug introduced by
The method willReturn() does not exist on Sylius\Component\Core\Mo...ChannelPricingInterface. ( Ignorable by Annotation )

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

48
        $productVariant->getChannelPricingForChannel($channel)->/** @scrutinizer ignore-call */ willReturn($channelPricing);

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...
49
50
        $moneyFormatter->format(10, 'USD');
51
52
        $this->transform($product);
0 ignored issues
show
Bug introduced by
The method transform() does not exist on spec\BitBag\SyliusElasti...lPricingTransformerSpec. 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

52
        $this->/** @scrutinizer ignore-call */ 
53
               transform($product);
Loading history...
53
    }
54
}
55