|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace spec\Gweb\SyliusProductDepositPlugin\Templating\Helper; |
|
6
|
|
|
|
|
7
|
|
|
use Gweb\SyliusProductDepositPlugin\Entity\ChannelDepositInterface; |
|
8
|
|
|
use Gweb\SyliusProductDepositPlugin\Entity\ProductVariantInterface; |
|
9
|
|
|
use Gweb\SyliusProductDepositPlugin\Provider\ProductVariantsDepositsProviderInterface; |
|
10
|
|
|
use Gweb\SyliusProductDepositPlugin\Templating\Helper\ProductVariantsDepositHelper; |
|
11
|
|
|
use PhpSpec\ObjectBehavior; |
|
12
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
|
13
|
|
|
use Sylius\Component\Core\Model\ProductInterface; |
|
14
|
|
|
use Symfony\Component\Templating\Helper\Helper; |
|
15
|
|
|
|
|
16
|
|
|
class ProductVariantsDepositHelperSpec extends ObjectBehavior |
|
17
|
|
|
{ |
|
18
|
|
|
function let( |
|
|
|
|
|
|
19
|
|
|
ProductVariantsDepositsProviderInterface $productVariantsDepositsProvider |
|
20
|
|
|
): void { |
|
21
|
|
|
$this->beConstructedWith($productVariantsDepositsProvider); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function it_is_initializable(): void |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
$this->shouldHaveType(ProductVariantsDepositHelper::class); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function it_extends_templating_helper(): void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->shouldHaveType(Helper::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_returns_single_product_variant_deposit_price( |
|
35
|
|
|
ProductVariantInterface $productVariant, |
|
36
|
|
|
ChannelInterface $channel, |
|
37
|
|
|
ChannelDepositInterface $channelDeposit |
|
38
|
|
|
): void { |
|
39
|
|
|
$channelDeposit->getPrice()->willReturn(50); |
|
40
|
|
|
|
|
41
|
|
|
$productVariant->getChannelDepositForChannel($channel)->willReturn($channelDeposit); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
$this->getDeposit($productVariant, $channel)->shouldReturn(50); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_returns_all_product_variants_deposit_prices( |
|
47
|
|
|
ProductVariantsDepositsProviderInterface $productVariantsDepositsProvider, |
|
48
|
|
|
ProductInterface $product, |
|
49
|
|
|
ChannelInterface $channel |
|
50
|
|
|
): void { |
|
51
|
|
|
$productVariantsDepositsProvider->provideVariantsDeposits($product, $channel)->willReturn([1 => 50, 2 => 100]); |
|
52
|
|
|
$this->beConstructedWith($productVariantsDepositsProvider); |
|
53
|
|
|
|
|
54
|
|
|
$this->getDepositsByProduct($product, $channel)->shouldReturn([1 => 50, 2 => 100]); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
function it_has_name() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->getName()->shouldReturn('gweb_product_variants_deposit'); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
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.