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