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

it_implements_context_interface()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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