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\Model\ZoneInterface; |
17
|
|
|
use Sylius\Component\Resource\Repository\RepositoryInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @author Łukasz Chruściel <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class ZoneContextSpec extends ObjectBehavior |
23
|
|
|
{ |
24
|
|
|
function let( |
25
|
|
|
RepositoryInterface $zoneRepository |
26
|
|
|
) { |
27
|
|
|
$this->beConstructedWith($zoneRepository); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
function it_is_initializable() |
31
|
|
|
{ |
32
|
|
|
$this->shouldHaveType('Sylius\Behat\Context\Transform\ZoneContext'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function it_implements_context_interface() |
36
|
|
|
{ |
37
|
|
|
$this->shouldImplement(Context::class); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function it_returns_zone_by_its_code($zoneRepository, ZoneInterface $zone) |
41
|
|
|
{ |
42
|
|
|
$zoneRepository->findOneBy(['code' => 'EU'])->willReturn($zone); |
43
|
|
|
|
44
|
|
|
$this->getZoneByCode('EU')->shouldReturn($zone); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
function it_throws_exception_if_zone_with_given_code_does_not_exist($zoneRepository) |
48
|
|
|
{ |
49
|
|
|
$zoneRepository->findOneBy(['code' => 'EU'])->willReturn(null); |
50
|
|
|
|
51
|
|
|
$this->shouldThrow(new \Exception('Zone with code "EU" does not exist.'))->during('getZoneByCode', ['EU']); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function it_returns_the_rest_of_the_world_zone($zoneRepository, ZoneInterface $zone) |
55
|
|
|
{ |
56
|
|
|
$zoneRepository->findOneBy(['code' => 'RoW'])->willReturn($zone); |
57
|
|
|
|
58
|
|
|
$this->getRestOfTheWorldZone()->shouldReturn($zone); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function it_throws_exception_if_there_is_no_rest_of_the_world_zone($zoneRepository) |
62
|
|
|
{ |
63
|
|
|
$zoneRepository->findOneBy(['code' => 'RoW'])->willReturn(null); |
64
|
|
|
|
65
|
|
|
$this->shouldThrow(new \Exception('Rest of the world zone does not exist.'))->during('getRestOfTheWorldZone'); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|