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\Addressing\Converter\CountryNameConverterInterface;
17
use Sylius\Component\Addressing\Model\AddressInterface;
18
use Sylius\Component\Resource\Factory\FactoryInterface;
19
20
/**
21
 * @author Łukasz Chruściel <[email protected]>
22
 */
23
class AddressingContextSpec extends ObjectBehavior
24
{
25
    function let(
26
        FactoryInterface $addressFactory,
27
        CountryNameConverterInterface $countryNameConverter
28
    ) {
29
        $this->beConstructedWith($addressFactory, $countryNameConverter);
30
    }
31
32
    function it_is_initializable()
33
    {
34
        $this->shouldHaveType('Sylius\Behat\Context\Transform\AddressingContext');
35
    }
36
37
    function it_implements_context_interface()
38
    {
39
        $this->shouldImplement(Context::class);
40
    }
41
42
    function it_creates_new_address_based_on_given_country(
43
        AddressInterface $address,
44
        FactoryInterface $addressFactory,
45
        CountryNameConverterInterface $countryNameConverter
46
    ) {
47
        $countryNameConverter->convertToCode('France')->willReturn('FR');
48
49
        $addressFactory->createNew()->willReturn($address);
50
51
        $address->setCountryCode('FR')->shouldBeCalled();
52
        $address->setFirstName('John')->shouldBeCalled();
53
        $address->setLastName('Doe')->shouldBeCalled();
54
        $address->setCity('Ankh Morpork')->shouldBeCalled();
55
        $address->setStreet('Frost Alley')->shouldBeCalled();
56
        $address->setPostcode('90210')->shouldBeCalled();
57
58
        $this->createNewAddress('France')->shouldReturn($address);
59
    }
60
}
61