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 spec\Sylius\Behat\Context\Domain; |
13
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
15
|
|
|
use PhpSpec\Exception\Example\NotEqualException; |
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Component\Core\Model\ShipmentInterface; |
18
|
|
|
use Sylius\Component\Core\Model\ShippingMethodInterface; |
19
|
|
|
use Sylius\Component\Core\Repository\ShipmentRepositoryInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Łukasz Chruściel <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class ShippingContextSpec extends ObjectBehavior |
25
|
|
|
{ |
26
|
|
|
function let(ShipmentRepositoryInterface $shippingRepository) |
27
|
|
|
{ |
28
|
|
|
$this->beConstructedWith($shippingRepository); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function it_is_initializable() |
32
|
|
|
{ |
33
|
|
|
$this->shouldHaveType('Sylius\Behat\Context\Domain\ShippingContext'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
function it_implements_context_interface() |
37
|
|
|
{ |
38
|
|
|
$this->shouldImplement(Context::class); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
function it_checks_if_an_shipment_exists_in_repository( |
42
|
|
|
ShipmentRepositoryInterface $shippingRepository, |
43
|
|
|
ShippingMethodInterface $freeDeliveryShipmentMethod |
44
|
|
|
) { |
45
|
|
|
$shippingRepository->findBy(['method' => $freeDeliveryShipmentMethod])->willReturn([]); |
46
|
|
|
|
47
|
|
|
$this->shipmentShouldNotExistInTheRegistry($freeDeliveryShipmentMethod); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_throws_an_exception_if_shipment_still_exist( |
51
|
|
|
ShipmentRepositoryInterface $shippingRepository, |
52
|
|
|
ShippingMethodInterface $dhlShipmentMethod, |
53
|
|
|
ShipmentInterface $shipment |
54
|
|
|
) { |
55
|
|
|
$shippingRepository->findBy(['method' => $dhlShipmentMethod])->willReturn([$shipment]); |
56
|
|
|
|
57
|
|
|
$this->shouldThrow(NotEqualException::class)->during('shipmentShouldNotExistInTheRegistry', [$dhlShipmentMethod]); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|