1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace spec\Gweb\SyliusProductDepositPlugin\Entity; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Collections\Collection; |
8
|
|
|
use Gweb\SyliusProductDepositPlugin\Entity\ChannelDepositInterface; |
9
|
|
|
|
10
|
|
|
use Gweb\SyliusProductDepositPlugin\Entity\ProductVariant; |
11
|
|
|
use Gweb\SyliusProductDepositPlugin\Entity\ProductVariantInterface; |
12
|
|
|
use PhpSpec\ObjectBehavior; |
13
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
14
|
|
|
use Sylius\Component\Taxation\Model\TaxCategoryInterface; |
15
|
|
|
|
16
|
|
|
final class ProductVariantSpec extends ObjectBehavior |
17
|
|
|
{ |
18
|
|
|
function it_is_sylius_product_variant(): void |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
$this->shouldHaveType(ProductVariant::class); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
function it_implements_product_variant_interface(): void |
24
|
|
|
{ |
25
|
|
|
$this->shouldImplement(ProductVariantInterface::class); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
function it_has_no_default_channel_deposits(): void |
29
|
|
|
{ |
30
|
|
|
$this->getChannelDeposits()->shouldReturnAnInstanceOf(Collection::class); |
|
|
|
|
31
|
|
|
$this->getChannelDeposits()->shouldHaveCount(0); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
function it_has_channel_deposit_for_channel(ChannelInterface $channel, ChannelDepositInterface $channelDeposit): void |
35
|
|
|
{ |
36
|
|
|
$this->getChannelDepositForChannel($channel)->shouldReturn(null); |
|
|
|
|
37
|
|
|
|
38
|
|
|
$this->addChannelDeposit($channelDeposit); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$this->hasChannelDeposit($channelDeposit)->shouldReturn(true); |
|
|
|
|
41
|
|
|
$this->hasChannelDepositForChannel($channel)->shouldReturn(true); |
|
|
|
|
42
|
|
|
|
43
|
|
|
$this->getChannelDepositForChannel($channel)->shouldReturn($channelDeposit); |
44
|
|
|
|
45
|
|
|
$this->removeChannelDeposit($channelDeposit); |
|
|
|
|
46
|
|
|
|
47
|
|
|
$this->hasChannelDeposit($channelDeposit)->shouldReturn(false); |
48
|
|
|
$this->hasChannelDepositForChannel($channel)->shouldReturn(false); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
function it_has_tax_category(TaxCategoryInterface $taxCategory): void |
52
|
|
|
{ |
53
|
|
|
$this->getDepositTaxCategory()->shouldReturn(null); |
|
|
|
|
54
|
|
|
$this->setDepositTaxCategory(null); |
|
|
|
|
55
|
|
|
|
56
|
|
|
$this->setDepositTaxCategory($taxCategory); |
57
|
|
|
$this->getDepositTaxCategory()->shouldReturn($taxCategory); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
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.