|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Component\Core\Model; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Component\Addressing\Model\ZoneInterface; |
|
18
|
|
|
use Sylius\Component\Core\Model\ChannelInterface; |
|
19
|
|
|
use Sylius\Component\Core\Model\ShippingMethod; |
|
20
|
|
|
use Sylius\Component\Core\Model\ShippingMethodInterface; |
|
21
|
|
|
use Sylius\Component\Shipping\Model\ShippingMethod as BaseShippingMethod; |
|
22
|
|
|
use Sylius\Component\Taxation\Model\TaxCategoryInterface; |
|
23
|
|
|
|
|
24
|
|
|
final class ShippingMethodSpec extends ObjectBehavior |
|
25
|
|
|
{ |
|
26
|
|
|
function it_is_initializable(): void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->shouldHaveType(ShippingMethod::class); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
function it_implements_a_shipping_method_interface(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$this->shouldImplement(ShippingMethodInterface::class); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function it_extends_a_shipping_method(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->shouldHaveType(BaseShippingMethod::class); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
function it_does_not_have_any_zone_defined_by_default(): void |
|
42
|
|
|
{ |
|
43
|
|
|
$this->getZone()->shouldReturn(null); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
function it_allows_defining_zone(ZoneInterface $zone): void |
|
47
|
|
|
{ |
|
48
|
|
|
$this->setZone($zone); |
|
49
|
|
|
$this->getZone()->shouldReturn($zone); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
function its_tax_category_is_mutable(TaxCategoryInterface $category): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->setTaxCategory($category); |
|
55
|
|
|
$this->getTaxCategory()->shouldReturn($category); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
function it_has_channels_collection(ChannelInterface $firstChannel, ChannelInterface $secondChannel): void |
|
59
|
|
|
{ |
|
60
|
|
|
$this->addChannel($firstChannel); |
|
61
|
|
|
$this->addChannel($secondChannel); |
|
62
|
|
|
|
|
63
|
|
|
$this->getChannels()->shouldIterateAs([$firstChannel, $secondChannel]); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function it_can_add_and_remove_channels(ChannelInterface $channel): void |
|
67
|
|
|
{ |
|
68
|
|
|
$this->addChannel($channel); |
|
69
|
|
|
$this->hasChannel($channel)->shouldReturn(true); |
|
70
|
|
|
|
|
71
|
|
|
$this->removeChannel($channel); |
|
72
|
|
|
$this->hasChannel($channel)->shouldReturn(false); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|