Completed
Push — master ( 59db0f...abafe8 )
by Kamil
18:55
created

ShippingContextSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 3
dl 0
loc 36
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 4 1
A it_is_initializable() 0 4 1
A it_implements_context_interface() 0 4 1
A it_checks_if_an_shipment_exists_in_repository() 0 8 1
A it_throws_an_exception_if_shipment_still_exist() 0 9 1
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