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\Ui\Admin; |
13
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
15
|
|
|
use PhpSpec\Exception\Example\NotEqualException; |
16
|
|
|
use PhpSpec\ObjectBehavior; |
17
|
|
|
use Sylius\Behat\Context\Ui\Admin\ManagingLocaleContext; |
18
|
|
|
use Sylius\Behat\Page\Admin\Crud\IndexPageInterface; |
19
|
|
|
use Sylius\Behat\Page\Admin\Locale\CreatePageInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @mixin ManagingLocaleContext |
23
|
|
|
* |
24
|
|
|
* @author Łukasz Chruściel <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class ManagingLocaleContextSpec extends ObjectBehavior |
27
|
|
|
{ |
28
|
|
|
function let(IndexPageInterface $indexPage, CreatePageInterface $createPage) |
29
|
|
|
{ |
30
|
|
|
$this->beConstructedWith($indexPage, $createPage); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
function it_is_initializable() |
34
|
|
|
{ |
35
|
|
|
$this->shouldHaveType('Sylius\Behat\Context\Ui\Admin\ManagingLocaleContext'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
function it_implements_context_interface() |
39
|
|
|
{ |
40
|
|
|
$this->shouldImplement(Context::class); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
function it_opens_locale_creation_page(CreatePageInterface $createPage) |
44
|
|
|
{ |
45
|
|
|
$createPage->open()->shouldBeCalled(); |
46
|
|
|
|
47
|
|
|
$this->iWantToCreateNewLocale(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
function it_chooses_locale_name(CreatePageInterface $createPage) |
51
|
|
|
{ |
52
|
|
|
$createPage->chooseName('Norwegian')->shouldBeCalled(); |
53
|
|
|
|
54
|
|
|
$this->iChoose('Norwegian'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
function it_creates_a_resource(CreatePageInterface $createPage) |
58
|
|
|
{ |
59
|
|
|
$createPage->create()->shouldBeCalled(); |
60
|
|
|
|
61
|
|
|
$this->iAdd(); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
function it_asserts_that_resource_was_successfully_created(IndexPageInterface $indexPage) |
65
|
|
|
{ |
66
|
|
|
$indexPage->hasSuccessMessage()->willReturn(true); |
67
|
|
|
$indexPage->isSuccessfullyCreated()->willReturn(true); |
68
|
|
|
|
69
|
|
|
$this->iShouldBeNotifiedAboutSuccess(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
function it_throws_an_exception_if_there_is_no_success_message(IndexPageInterface $indexPage) |
73
|
|
|
{ |
74
|
|
|
$indexPage->hasSuccessMessage()->willReturn(false); |
75
|
|
|
$indexPage->isSuccessfullyCreated()->willReturn(true); |
76
|
|
|
|
77
|
|
|
$this->shouldThrow(NotEqualException::class)->during('iShouldBeNotifiedAboutSuccess'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
function it_throws_an_exception_if_resource_was_not_successfully_created(IndexPageInterface $indexPage) |
81
|
|
|
{ |
82
|
|
|
$indexPage->hasSuccessMessage()->willReturn(true); |
83
|
|
|
$indexPage->isSuccessfullyCreated()->willReturn(false); |
84
|
|
|
|
85
|
|
|
$this->shouldThrow(NotEqualException::class)->during('iShouldBeNotifiedAboutSuccess'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
function it_asserts_if_store_is_available_in_given_language(IndexPageInterface $indexPage) |
89
|
|
|
{ |
90
|
|
|
$indexPage->isResourceOnPage(['name' => 'Norwegian'])->willReturn(true); |
91
|
|
|
|
92
|
|
|
$this->storeShouldBeAvailableInLanguage('Norwegian'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
function it_throws_an_exception_if_resource_can_not_be_founded_on_page(IndexPageInterface $indexPage) |
96
|
|
|
{ |
97
|
|
|
$indexPage->isResourceOnPage(['name' => 'Norwegian'])->willReturn(false); |
98
|
|
|
|
99
|
|
|
$this->shouldThrow(NotEqualException::class)->during('storeShouldBeAvailableInLanguage', ['Norwegian']); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|