|
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\Bundle\ThemeBundle\Translation\Loader; |
|
13
|
|
|
|
|
14
|
|
|
use PhpSpec\ObjectBehavior; |
|
15
|
|
|
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface; |
|
16
|
|
|
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface; |
|
17
|
|
|
use Sylius\Bundle\ThemeBundle\Translation\Loader\ThemeAwareLoader; |
|
18
|
|
|
use Symfony\Component\Translation\Loader\LoaderInterface; |
|
19
|
|
|
use Symfony\Component\Translation\MessageCatalogueInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @mixin ThemeAwareLoader |
|
23
|
|
|
* |
|
24
|
|
|
* @author Kamil Kokot <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class ThemeAwareLoaderSpec extends ObjectBehavior |
|
27
|
|
|
{ |
|
28
|
|
|
function let(LoaderInterface $loader, ThemeRepositoryInterface $themeRepository) |
|
29
|
|
|
{ |
|
30
|
|
|
$this->beConstructedWith($loader, $themeRepository); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
function it_is_initializable() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->shouldHaveType('Sylius\Bundle\ThemeBundle\Translation\Loader\ThemeAwareLoader'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
function it_implements_translation_loader_interface() |
|
39
|
|
|
{ |
|
40
|
|
|
$this->shouldImplement(LoaderInterface::class); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
function it_does_not_change_anything_if_given_file_is_not_included_in_any_theme( |
|
44
|
|
|
LoaderInterface $loader, |
|
45
|
|
|
ThemeRepositoryInterface $themeRepository, |
|
46
|
|
|
MessageCatalogueInterface $messageCatalogue |
|
47
|
|
|
) { |
|
48
|
|
|
$loader->load('/theme/resource.en.xml', 'en', 'messages')->willReturn($messageCatalogue); |
|
49
|
|
|
|
|
50
|
|
|
$themeRepository->findOneByPath('/theme/resource.en.xml')->shouldBeCalled()->willReturn(null); |
|
51
|
|
|
|
|
52
|
|
|
$this->load('/theme/resource.en.xml', 'en', 'messages')->shouldReturn($messageCatalogue); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
function it_adds_theme_slug_to_keys_if_given_file_is_included_in_theme( |
|
56
|
|
|
LoaderInterface $loader, |
|
57
|
|
|
ThemeRepositoryInterface $themeRepository, |
|
58
|
|
|
MessageCatalogueInterface $messageCatalogue, |
|
59
|
|
|
ThemeInterface $theme |
|
60
|
|
|
) { |
|
61
|
|
|
$loader->load('/theme/resource.en.xml', 'en', 'messages')->willReturn($messageCatalogue); |
|
62
|
|
|
|
|
63
|
|
|
$themeRepository->findOneByPath('/theme/resource.en.xml')->willReturn($theme); |
|
64
|
|
|
$theme->getSlug()->willReturn('sylius/sample-theme'); |
|
65
|
|
|
|
|
66
|
|
|
$messageCatalogue->all('messages')->willReturn(['key' => 'value']); |
|
67
|
|
|
$messageCatalogue->replace(['key|sylius/sample-theme' => 'value'], 'messages')->shouldBeCalled(); |
|
68
|
|
|
|
|
69
|
|
|
$this->load('/theme/resource.en.xml', 'en', 'messages')->shouldReturn($messageCatalogue); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|