1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the eZ Publish Kernel package. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Tests\Imagine; |
10
|
|
|
|
11
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Imagine\PlaceholderAliasGenerator; |
12
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Imagine\PlaceholderAliasGeneratorConfigurator; |
13
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Imagine\PlaceholderProvider; |
14
|
|
|
use eZ\Bundle\EzPublishCoreBundle\Imagine\PlaceholderProviderRegistry; |
15
|
|
|
use eZ\Publish\Core\MVC\ConfigResolverInterface; |
16
|
|
|
use PHPUnit\Framework\TestCase; |
17
|
|
|
|
18
|
|
|
class PlaceholderAliasGeneratorConfiguratorTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
const BINARY_HANDLER_NAME = 'default'; |
21
|
|
|
const PROVIDER_TYPE = 'generic'; |
22
|
|
|
const PROVIDER_OPTIONS = [ |
23
|
|
|
'a' => 'A', |
24
|
|
|
'b' => 'B', |
25
|
|
|
'c' => 'C', |
26
|
|
|
]; |
27
|
|
|
|
28
|
|
|
public function testConfigure() |
29
|
|
|
{ |
30
|
|
|
$configResolver = $this->createMock(ConfigResolverInterface::class); |
31
|
|
|
$configResolver |
32
|
|
|
->expects($this->once()) |
33
|
|
|
->method('getParameter') |
34
|
|
|
->with('io.binarydata_handler') |
35
|
|
|
->willReturn(self::BINARY_HANDLER_NAME); |
36
|
|
|
|
37
|
|
|
$provider = $this->createMock(PlaceholderProvider::class); |
38
|
|
|
|
39
|
|
|
$providerRegistry = $this->createMock(PlaceholderProviderRegistry::class); |
40
|
|
|
$providerRegistry |
41
|
|
|
->expects($this->once()) |
42
|
|
|
->method('getProvider') |
43
|
|
|
->with(self::PROVIDER_TYPE) |
44
|
|
|
->willReturn($provider); |
45
|
|
|
|
46
|
|
|
$providerConfig = [ |
47
|
|
|
self::BINARY_HANDLER_NAME => [ |
48
|
|
|
'provider' => self::PROVIDER_TYPE, |
49
|
|
|
'options' => self::PROVIDER_OPTIONS, |
50
|
|
|
], |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
$generator = $this->createMock(PlaceholderAliasGenerator::class); |
54
|
|
|
$generator |
55
|
|
|
->expects($this->once()) |
56
|
|
|
->method('setPlaceholderProvider') |
57
|
|
|
->with($provider, self::PROVIDER_OPTIONS); |
58
|
|
|
|
59
|
|
|
$configurator = new PlaceholderAliasGeneratorConfigurator( |
60
|
|
|
$configResolver, |
61
|
|
|
$providerRegistry, |
62
|
|
|
$providerConfig |
63
|
|
|
); |
64
|
|
|
$configurator->configure($generator); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|