|
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 |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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(); |
|
|
|
|
|
|
39
|
|
|
$channelDeposit->setProductVariant(null)->shouldBeCalled(); |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
$this->hasChannelDeposit($channelDeposit)->shouldReturn(false); |
|
|
|
|
|
|
42
|
|
|
$this->hasChannelDepositForChannel($channel)->shouldReturn(false); |
|
|
|
|
|
|
43
|
|
|
$this->getChannelDepositForChannel($channel)->shouldReturn(null); |
|
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
$this->addChannelDeposit($channelDeposit); |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
$this->hasChannelDeposit($channelDeposit)->shouldReturn(true); |
|
48
|
|
|
$this->hasChannelDepositForChannel($channel)->shouldReturn(true); |
|
49
|
|
|
$this->getChannelDepositForChannel($channel)->shouldReturn($channelDeposit); |
|
50
|
|
|
|
|
51
|
|
|
$this->removeChannelDeposit($channelDeposit); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
61
|
|
|
$this->setDepositTaxCategory($taxCategory); |
|
|
|
|
|
|
62
|
|
|
$this->getDepositTaxCategory()->shouldReturn($taxCategory); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.