Completed
Push — master ( 4f4b30...79d213 )
by Kamil
49:20 queued 33s
created

AddressingContextSpec::let()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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