|
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
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace spec\Sylius\Bundle\ThemeBundle\Configuration\Filesystem; |
|
15
|
|
|
|
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\ConfigurationProviderInterface; |
|
18
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\Filesystem\ConfigurationLoaderInterface; |
|
19
|
|
|
use Sylius\Bundle\ThemeBundle\Configuration\Filesystem\FilesystemConfigurationProvider; |
|
20
|
|
|
use Sylius\Bundle\ThemeBundle\Locator\FileLocatorInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @author Kamil Kokot <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
final class FilesystemConfigurationProviderSpec extends ObjectBehavior |
|
26
|
|
|
{ |
|
27
|
|
|
function let(FileLocatorInterface $fileLocator, ConfigurationLoaderInterface $loader): void |
|
28
|
|
|
{ |
|
29
|
|
|
$this->beConstructedWith($fileLocator, $loader, 'configurationfile.json'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
function it_implements_configuration_provider_interface(): void |
|
33
|
|
|
{ |
|
34
|
|
|
$this->shouldImplement(ConfigurationProviderInterface::class); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
function it_provides_loaded_configuration_files(FileLocatorInterface $fileLocator, ConfigurationLoaderInterface $loader): void |
|
38
|
|
|
{ |
|
39
|
|
|
$fileLocator->locateFilesNamed('configurationfile.json')->willReturn([ |
|
40
|
|
|
'/cristopher/configurationfile.json', |
|
41
|
|
|
'/richard/configurationfile.json', |
|
42
|
|
|
]); |
|
43
|
|
|
|
|
44
|
|
|
$loader->load('/cristopher/configurationfile.json')->willReturn(['name' => 'cristopher/sylius-theme']); |
|
45
|
|
|
$loader->load('/richard/configurationfile.json')->willReturn(['name' => 'richard/sylius-theme']); |
|
46
|
|
|
|
|
47
|
|
|
$this->getConfigurations()->shouldReturn([ |
|
48
|
|
|
['name' => 'cristopher/sylius-theme'], |
|
49
|
|
|
['name' => 'richard/sylius-theme'], |
|
50
|
|
|
]); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
function it_provides_an_empty_array_if_there_were_no_themes_found(FileLocatorInterface $fileLocator): void |
|
54
|
|
|
{ |
|
55
|
|
|
$fileLocator->locateFilesNamed('configurationfile.json')->willThrow(\InvalidArgumentException::class); |
|
56
|
|
|
|
|
57
|
|
|
$this->getConfigurations()->shouldReturn([]); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|