Completed
Pull Request — master (#54)
by Konrad
08:53
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
/*
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\SyliusElasticsearchPlugin\Transformer\Product;
14
15
use BitBag\SyliusElasticsearchPlugin\Transformer\Product\TransformerInterface;
16
use PhpSpec\ObjectBehavior;
17
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
18
use Sylius\Component\Channel\Context\ChannelContextInterface;
19
use Sylius\Component\Core\Model\ChannelInterface;
20
use Sylius\Component\Core\Model\ChannelPricingInterface;
21
use Sylius\Component\Core\Model\ProductInterface;
22
use Sylius\Component\Core\Model\ProductVariantInterface;
23
use Sylius\Component\Currency\Model\CurrencyInterface;
24
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
25
26
final class ChannelPricingTransformerSpec extends ObjectBehavior
27
{
28
    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...
29
        ChannelContextInterface $channelContext,
30
        ProductVariantResolverInterface $productVariantResolver,
31
        MoneyFormatterInterface $moneyFormatter
32
    ): void {
33
        $this->beConstructedWith($channelContext, $productVariantResolver, $moneyFormatter);
34
    }
35
36
    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...
37
    {
38
        $this->shouldImplement(TransformerInterface::class);
39
    }
40
41
    function it_transforms_product_channel_prices_into_formatted_price(
42
        ChannelContextInterface $channelContext,
43
        ProductVariantResolverInterface $productVariantResolver,
44
        MoneyFormatterInterface $moneyFormatter,
45
        CurrencyInterface $currency,
46
        ChannelInterface $channel,
47
        ProductVariantInterface $productVariant,
48
        ProductInterface $product,
49
        ChannelPricingInterface $channelPricing
50
    ): void {
51
        $currency->getCode()->willReturn('USD');
52
        $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

52
        $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...
53
        $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

53
        $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...
54
        $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

54
        $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...
55
        $channelPricing->getPrice()->willReturn(10);
56
        $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

56
        $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...
57
58
        $moneyFormatter->format(10, 'USD');
59
60
        $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

60
        $this->/** @scrutinizer ignore-call */ 
61
               transform($product);
Loading history...
61
    }
62
}
63