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
|
|
|
|