|
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
|
|
|
namespace Sylius\Behat\Context\Setup; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
|
15
|
|
|
use Sylius\Component\Core\Test\Services\SharedStorageInterface; |
|
16
|
|
|
use Sylius\Component\Resource\Factory\FactoryInterface; |
|
17
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
|
18
|
|
|
use Sylius\Component\Shipping\Calculator\DefaultCalculators; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author Arkadiusz Krakowiak <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class ShippingContext implements Context |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var RepositoryInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
private $shippingMethodRepository; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var FactoryInterface |
|
32
|
|
|
*/ |
|
33
|
|
|
private $shippingMethodFactory; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var SharedStorageInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
private $sharedStorage; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param RepositoryInterface $shippingMethodRepository |
|
42
|
|
|
* @param FactoryInterface $shippingMethodFactory |
|
43
|
|
|
* @param SharedStorageInterface $sharedStorage |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct( |
|
46
|
|
|
RepositoryInterface $shippingMethodRepository, |
|
47
|
|
|
FactoryInterface $shippingMethodFactory, |
|
48
|
|
|
SharedStorageInterface $sharedStorage |
|
49
|
|
|
) { |
|
50
|
|
|
$this->shippingMethodRepository = $shippingMethodRepository; |
|
51
|
|
|
$this->shippingMethodFactory = $shippingMethodFactory; |
|
52
|
|
|
$this->sharedStorage = $sharedStorage; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @Given store ships everything for free |
|
57
|
|
|
*/ |
|
58
|
|
|
public function storeShipsEverythingForFree() |
|
59
|
|
|
{ |
|
60
|
|
|
$zone = $this->sharedStorage->getCurrentResource('zone'); |
|
61
|
|
|
|
|
62
|
|
|
$shippingMethod = $this->shippingMethodFactory->createNew(); |
|
63
|
|
|
$shippingMethod->setCode('SM1'); |
|
64
|
|
|
$shippingMethod->setName('Free'); |
|
65
|
|
|
$shippingMethod->setCurrentLocale('FR'); |
|
66
|
|
|
$shippingMethod->setConfiguration(array('amount' => 0)); |
|
67
|
|
|
$shippingMethod->setCalculator(DefaultCalculators::PER_ITEM_RATE); |
|
68
|
|
|
$shippingMethod->setZone($zone); |
|
69
|
|
|
|
|
70
|
|
|
$this->shippingMethodRepository->add($shippingMethod); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|