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