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 Sylius\Behat\Context\Ui\Admin; |
13
|
|
|
|
14
|
|
|
use Behat\Behat\Context\Context; |
15
|
|
|
use Sylius\Behat\Page\Admin\Administrator\UpdatePageInterface; |
16
|
|
|
use Sylius\Behat\Page\Admin\DashboardPageInterface; |
17
|
|
|
use Sylius\Component\Core\Model\AdminUserInterface; |
18
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
19
|
|
|
use Webmozart\Assert\Assert; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Jan Góralski <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class LocaleContext implements Context |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var UpdatePageInterface |
28
|
|
|
*/ |
29
|
|
|
private $adminUpdatePage; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var DashboardPageInterface |
33
|
|
|
*/ |
34
|
|
|
private $dashboardPage; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var TranslatorInterface |
38
|
|
|
*/ |
39
|
|
|
private $translator; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param UpdatePageInterface $adminUpdatePage |
43
|
|
|
* @param DashboardPageInterface $dashboardPage |
44
|
|
|
* @param TranslatorInterface $translator |
45
|
|
|
*/ |
46
|
|
|
public function __construct( |
47
|
|
|
UpdatePageInterface $adminUpdatePage, |
48
|
|
|
DashboardPageInterface $dashboardPage, |
49
|
|
|
TranslatorInterface $translator |
50
|
|
|
) { |
51
|
|
|
$this->adminUpdatePage = $adminUpdatePage; |
52
|
|
|
$this->dashboardPage = $dashboardPage; |
53
|
|
|
$this->translator = $translator; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Then I should be viewing the administration panel in :localeCode |
58
|
|
|
* @Then I should still be viewing the administration panel in :localeCode |
59
|
|
|
* @Then they should be viewing the administration panel in :localeCode |
60
|
|
|
*/ |
61
|
|
|
public function iShouldBeViewingTheAdministrationPanelIn($localeCode) |
62
|
|
|
{ |
63
|
|
|
$this->dashboardPage->open(); |
64
|
|
|
|
65
|
|
|
$expectedSubHeader = $this->translate('sylius.ui.overview_of_your_store', $localeCode); |
66
|
|
|
$actualSubHeader = $this->dashboardPage->getSubHeader(); |
67
|
|
|
|
68
|
|
|
Assert::same( |
69
|
|
|
$actualSubHeader, |
70
|
|
|
$expectedSubHeader, |
71
|
|
|
sprintf('Dashboard header should say "%s", but says "%s" instead.', $expectedSubHeader, $actualSubHeader) |
72
|
|
|
); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string $text |
77
|
|
|
* @param string $localeCode |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
private function translate($text, $localeCode) |
82
|
|
|
{ |
83
|
|
|
$this->translator->setLocale($localeCode); |
84
|
|
|
|
85
|
|
|
return $this->translator->trans($text); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|