Completed
Push — master ( eeff33...1702a2 )
by Kamil
41:57 queued 20:40
created

ShippingContextSpec   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A let() 0 3 1
A it_is_initializable() 0 4 1
A it_implements_context_interface() 0 4 1
A it_casts_shipping_method_name_to_string() 0 6 1
A it_throws_exception_if_there_is_no_shipping_method_with_name_passed_to_casting() 0 6 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\Transform;
13
14
use Behat\Behat\Context\Context;
15
use PhpSpec\ObjectBehavior;
16
use Sylius\Component\Core\Model\ShippingMethodInterface;
17
use Sylius\Component\Resource\Repository\RepositoryInterface;
18
19
/**
20
 * @author Łukasz Chruściel <[email protected]>
21
 */
22
class ShippingContextSpec extends ObjectBehavior
23
{
24
    function let(RepositoryInterface $shippingMethodRepository) {
25
        $this->beConstructedWith($shippingMethodRepository);
26
    }
27
28
    function it_is_initializable()
29
    {
30
        $this->shouldHaveType('Sylius\Behat\Context\Transform\ShippingContext');
31
    }
32
33
    function it_implements_context_interface()
34
    {
35
        $this->shouldImplement(Context::class);
36
    }
37
38
    function it_casts_shipping_method_name_to_string($shippingMethodRepository, ShippingMethodInterface $shippingMethod)
39
    {
40
        $shippingMethodRepository->findOneBy(['name' => 'DHL'])->willReturn($shippingMethod);
41
42
        $this->getShippingMethodByName('DHL')->shouldReturn($shippingMethod);
43
    }
44
45
    function it_throws_exception_if_there_is_no_shipping_method_with_name_passed_to_casting($shippingMethodRepository)
46
    {
47
        $shippingMethodRepository->findOneBy(['name' => 'DHL'])->willReturn(null);
48
49
        $this->shouldThrow(new \Exception('Shipping method with name "DHL" does not exist'))->during('getShippingMethodByName', ['DHL']);
50
    }
51
}
52