Passed
Push — master ( 9d9530...9d60e1 )
by G
07:54
created

ProductVariantSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 23
dl 0
loc 48
rs 10
c 1
b 0
f 1
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A it_has_channel_deposit_for_channel() 0 23 1
A it_implements_product_variant_interface() 0 3 1
A it_has_tax_category() 0 5 1
A it_has_no_default_channel_deposits() 0 4 1
A it_is_sylius_product_variant() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace spec\Gewebe\SyliusProductDepositPlugin\Entity;
6
7
use Doctrine\Common\Collections\Collection;
8
use Gewebe\SyliusProductDepositPlugin\Entity\ChannelDepositInterface;
9
use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariant;
10
use Gewebe\SyliusProductDepositPlugin\Entity\ProductVariantInterface;
11
use PhpSpec\ObjectBehavior;
12
use Sylius\Component\Core\Model\ChannelInterface;
13
use Sylius\Component\Taxation\Model\TaxCategoryInterface;
14
15
final class ProductVariantSpec extends ObjectBehavior
16
{
17
    function it_is_sylius_product_variant(): 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...
18
    {
19
        $this->shouldHaveType(ProductVariant::class);
20
    }
21
22
    function it_implements_product_variant_interface(): void
23
    {
24
        $this->shouldImplement(ProductVariantInterface::class);
25
    }
26
27
    function it_has_no_default_channel_deposits(): void
28
    {
29
        $this->getChannelDeposits()->shouldReturnAnInstanceOf(Collection::class);
0 ignored issues
show
Bug introduced by
The method getChannelDeposits() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

29
        $this->/** @scrutinizer ignore-call */ 
30
               getChannelDeposits()->shouldReturnAnInstanceOf(Collection::class);
Loading history...
30
        $this->getChannelDeposits()->shouldHaveCount(0);
31
    }
32
33
    function it_has_channel_deposit_for_channel(ChannelInterface $channel, ChannelDepositInterface $channelDeposit): void
34
    {
35
        $channel->getCode()->willReturn('de');
36
37
        $channelDeposit->getChannelCode()->willReturn('de');
38
        $channelDeposit->setProductVariant($this)->shouldBeCalled();
0 ignored issues
show
Bug introduced by
$this of type spec\Gewebe\SyliusProduc...tity\ProductVariantSpec is incompatible with the type Gewebe\SyliusProductDepo...ctVariantInterface|null expected by parameter $productVariants of Gewebe\SyliusProductDepo...ce::setProductVariant(). ( Ignorable by Annotation )

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

38
        $channelDeposit->setProductVariant(/** @scrutinizer ignore-type */ $this)->shouldBeCalled();
Loading history...
Bug introduced by
Are you sure the usage of $channelDeposit->setProductVariant($this) targeting Gewebe\SyliusProductDepo...ce::setProductVariant() 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...
39
        $channelDeposit->setProductVariant(null)->shouldBeCalled();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $channelDeposit->setProductVariant(null) targeting Gewebe\SyliusProductDepo...ce::setProductVariant() 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...
40
41
        $this->hasChannelDeposit($channelDeposit)->shouldReturn(false);
0 ignored issues
show
Bug introduced by
The method hasChannelDeposit() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

41
        $this->/** @scrutinizer ignore-call */ 
42
               hasChannelDeposit($channelDeposit)->shouldReturn(false);
Loading history...
42
        $this->hasChannelDepositForChannel($channel)->shouldReturn(false);
0 ignored issues
show
Bug introduced by
The method hasChannelDepositForChannel() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

42
        $this->/** @scrutinizer ignore-call */ 
43
               hasChannelDepositForChannel($channel)->shouldReturn(false);
Loading history...
43
        $this->getChannelDepositForChannel($channel)->shouldReturn(null);
0 ignored issues
show
Bug introduced by
The method getChannelDepositForChannel() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

43
        $this->/** @scrutinizer ignore-call */ 
44
               getChannelDepositForChannel($channel)->shouldReturn(null);
Loading history...
44
45
        $this->addChannelDeposit($channelDeposit);
0 ignored issues
show
Bug introduced by
The method addChannelDeposit() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

45
        $this->/** @scrutinizer ignore-call */ 
46
               addChannelDeposit($channelDeposit);
Loading history...
46
47
        $this->hasChannelDeposit($channelDeposit)->shouldReturn(true);
48
        $this->hasChannelDepositForChannel($channel)->shouldReturn(true);
49
        $this->getChannelDepositForChannel($channel)->shouldReturn($channelDeposit);
50
51
        $this->removeChannelDeposit($channelDeposit);
0 ignored issues
show
Bug introduced by
The method removeChannelDeposit() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

51
        $this->/** @scrutinizer ignore-call */ 
52
               removeChannelDeposit($channelDeposit);
Loading history...
52
53
        $this->hasChannelDeposit($channelDeposit)->shouldReturn(false);
54
        $this->hasChannelDepositForChannel($channel)->shouldReturn(false);
55
        $this->getChannelDepositForChannel($channel)->shouldReturn(null);
56
    }
57
58
    function it_has_tax_category(TaxCategoryInterface $taxCategory): void
59
    {
60
        $this->getDepositTaxCategory()->shouldReturn(null);
0 ignored issues
show
Bug introduced by
The method getDepositTaxCategory() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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
               getDepositTaxCategory()->shouldReturn(null);
Loading history...
61
        $this->setDepositTaxCategory($taxCategory);
0 ignored issues
show
Bug introduced by
The method setDepositTaxCategory() does not exist on spec\Gewebe\SyliusProduc...tity\ProductVariantSpec. 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

61
        $this->/** @scrutinizer ignore-call */ 
62
               setDepositTaxCategory($taxCategory);
Loading history...
62
        $this->getDepositTaxCategory()->shouldReturn($taxCategory);
63
    }
64
}
65