|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file has been created by the developers from BitBag. |
|
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
|
6
|
|
|
* another great project. |
|
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
|
8
|
|
|
* an email on [email protected]. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types=1); |
|
12
|
|
|
|
|
13
|
|
|
namespace spec\BitBag\SyliusShippingExportPlugin\Entity; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusShippingExportPlugin\Entity\ShippingExportInterface; |
|
16
|
|
|
use BitBag\SyliusShippingExportPlugin\Entity\ShippingGateway; |
|
17
|
|
|
use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface; |
|
18
|
|
|
use Doctrine\Common\Collections\Collection; |
|
19
|
|
|
use PhpSpec\ObjectBehavior; |
|
20
|
|
|
use Sylius\Component\Core\Model\ShippingMethodInterface; |
|
21
|
|
|
use Sylius\Component\Resource\Model\ResourceInterface; |
|
22
|
|
|
|
|
23
|
|
|
final class ShippingGatewaySpec extends ObjectBehavior |
|
24
|
|
|
{ |
|
25
|
|
|
function it_is_initializable() |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
$this->shouldHaveType(ShippingGateway::class); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
function it_is_resource() |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$this->shouldImplement(ResourceInterface::class); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
function it_implements_shipping_gateway_interface() |
|
|
|
|
|
|
36
|
|
|
{ |
|
37
|
|
|
$this->shouldImplement(ShippingGatewayInterface::class); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
function it_returns_array_collection_when_initialized() |
|
|
|
|
|
|
41
|
|
|
{ |
|
42
|
|
|
$this->getShippingMethods()->shouldHaveType(Collection::class); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function it_adds_shipping_method(ShippingMethodInterface $shippingMethod) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$this->addShippingMethod($shippingMethod); |
|
48
|
|
|
|
|
49
|
|
|
$this->getShippingMethods()->first()->shouldReturn($shippingMethod); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
function it_initializes_a_shipping_export_collection_by_default() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
$this->getShippingExports()->shouldHaveType(Collection::class); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
function it_adds_a_shipping_export(ShippingExportInterface $shippingExport) |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
$this->addShippingExport($shippingExport); |
|
60
|
|
|
$this->hasShippingExport($shippingExport)->shouldReturn(true); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
function it_removes_a_shipping_export(ShippingExportInterface $shippingExport) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
$this->addShippingExport($shippingExport); |
|
66
|
|
|
$this->removeShippingExport($shippingExport); |
|
67
|
|
|
|
|
68
|
|
|
$this->hasShippingExport($shippingExport)->shouldReturn(false); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
function it_returns_config_value() |
|
|
|
|
|
|
72
|
|
|
{ |
|
73
|
|
|
$this->setConfig(['foo' => 'bar']); |
|
74
|
|
|
|
|
75
|
|
|
$this->getConfigValue('foo')->shouldReturn('bar'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
function it_throws_error_while_trying_to_access_not_existing_config_value() |
|
|
|
|
|
|
79
|
|
|
{ |
|
80
|
|
|
$this->setConfig(['foo' => 'bar']); |
|
81
|
|
|
|
|
82
|
|
|
$this->shouldThrow(\InvalidArgumentException::class)->during('getConfigValue', ['bar']); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
This check marks method names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString.